YYTextUtilities.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // YYTextUtilities.m
  3. // YYKit <https://github.com/ibireme/YYKit>
  4. //
  5. // Created by ibireme on 15/4/6.
  6. // Copyright (c) 2015 ibireme.
  7. //
  8. // This source code is licensed under the MIT-style license found in the
  9. // LICENSE file in the root directory of this source tree.
  10. //
  11. #import "YYTextUtilities.h"
  12. NSCharacterSet *YYTextVerticalFormRotateCharacterSet() {
  13. static NSMutableCharacterSet *set;
  14. static dispatch_once_t onceToken;
  15. dispatch_once(&onceToken, ^{
  16. set = [NSMutableCharacterSet new];
  17. [set addCharactersInRange:NSMakeRange(0x1100, 256)]; // Hangul Jamo
  18. [set addCharactersInRange:NSMakeRange(0x2460, 160)]; // Enclosed Alphanumerics
  19. [set addCharactersInRange:NSMakeRange(0x2600, 256)]; // Miscellaneous Symbols
  20. [set addCharactersInRange:NSMakeRange(0x2700, 192)]; // Dingbats
  21. [set addCharactersInRange:NSMakeRange(0x2E80, 128)]; // CJK Radicals Supplement
  22. [set addCharactersInRange:NSMakeRange(0x2F00, 224)]; // Kangxi Radicals
  23. [set addCharactersInRange:NSMakeRange(0x2FF0, 16)]; // Ideographic Description Characters
  24. [set addCharactersInRange:NSMakeRange(0x3000, 64)]; // CJK Symbols and Punctuation
  25. [set removeCharactersInRange:NSMakeRange(0x3008, 10)];
  26. [set removeCharactersInRange:NSMakeRange(0x3014, 12)];
  27. [set addCharactersInRange:NSMakeRange(0x3040, 96)]; // Hiragana
  28. [set addCharactersInRange:NSMakeRange(0x30A0, 96)]; // Katakana
  29. [set addCharactersInRange:NSMakeRange(0x3100, 48)]; // Bopomofo
  30. [set addCharactersInRange:NSMakeRange(0x3130, 96)]; // Hangul Compatibility Jamo
  31. [set addCharactersInRange:NSMakeRange(0x3190, 16)]; // Kanbun
  32. [set addCharactersInRange:NSMakeRange(0x31A0, 32)]; // Bopomofo Extended
  33. [set addCharactersInRange:NSMakeRange(0x31C0, 48)]; // CJK Strokes
  34. [set addCharactersInRange:NSMakeRange(0x31F0, 16)]; // Katakana Phonetic Extensions
  35. [set addCharactersInRange:NSMakeRange(0x3200, 256)]; // Enclosed CJK Letters and Months
  36. [set addCharactersInRange:NSMakeRange(0x3300, 256)]; // CJK Compatibility
  37. [set addCharactersInRange:NSMakeRange(0x3400, 2582)]; // CJK Unified Ideographs Extension A
  38. [set addCharactersInRange:NSMakeRange(0x4E00, 20941)]; // CJK Unified Ideographs
  39. [set addCharactersInRange:NSMakeRange(0xAC00, 11172)]; // Hangul Syllables
  40. [set addCharactersInRange:NSMakeRange(0xD7B0, 80)]; // Hangul Jamo Extended-B
  41. [set addCharactersInString:@""]; // U+F8FF (Private Use Area)
  42. [set addCharactersInRange:NSMakeRange(0xF900, 512)]; // CJK Compatibility Ideographs
  43. [set addCharactersInRange:NSMakeRange(0xFE10, 16)]; // Vertical Forms
  44. [set addCharactersInRange:NSMakeRange(0xFF00, 240)]; // Halfwidth and Fullwidth Forms
  45. [set addCharactersInRange:NSMakeRange(0x1F200, 256)]; // Enclosed Ideographic Supplement
  46. [set addCharactersInRange:NSMakeRange(0x1F300, 768)]; // Enclosed Ideographic Supplement
  47. [set addCharactersInRange:NSMakeRange(0x1F600, 80)]; // Emoticons (Emoji)
  48. [set addCharactersInRange:NSMakeRange(0x1F680, 128)]; // Transport and Map Symbols
  49. // See http://unicode-table.com/ for more information.
  50. });
  51. return set;
  52. }
  53. NSCharacterSet *YYTextVerticalFormRotateAndMoveCharacterSet() {
  54. static NSMutableCharacterSet *set;
  55. static dispatch_once_t onceToken;
  56. dispatch_once(&onceToken, ^{
  57. set = [NSMutableCharacterSet new];
  58. [set addCharactersInString:@",。、."];
  59. });
  60. return set;
  61. }