Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

942 lines
41 KiB

  1. /*
  2. File: TextCommon.h
  3. Contains: TextEncoding-related types and constants, and prototypes for related functions
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 1995-2002 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __TEXTCOMMON__
  11. #define __TEXTCOMMON__
  12. #ifndef __MACTYPES__
  13. #include <MacTypes.h>
  14. #endif
  15. #if PRAGMA_ONCE
  16. #pragma once
  17. #endif
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #if PRAGMA_IMPORT
  22. #pragma import on
  23. #endif
  24. #if PRAGMA_STRUCT_ALIGN
  25. #pragma options align=mac68k
  26. #elif PRAGMA_STRUCT_PACKPUSH
  27. #pragma pack(push, 2)
  28. #elif PRAGMA_STRUCT_PACK
  29. #pragma pack(2)
  30. #endif
  31. /* TextEncodingBase type & values */
  32. /* (values 0-32 correspond to the Script Codes defined in Inside Macintosh: Text pages 6-52 and 6-53 */
  33. typedef UInt32 TextEncodingBase;
  34. enum {
  35. /* Mac OS encodings*/
  36. kTextEncodingMacRoman = 0L,
  37. kTextEncodingMacJapanese = 1,
  38. kTextEncodingMacChineseTrad = 2,
  39. kTextEncodingMacKorean = 3,
  40. kTextEncodingMacArabic = 4,
  41. kTextEncodingMacHebrew = 5,
  42. kTextEncodingMacGreek = 6,
  43. kTextEncodingMacCyrillic = 7,
  44. kTextEncodingMacDevanagari = 9,
  45. kTextEncodingMacGurmukhi = 10,
  46. kTextEncodingMacGujarati = 11,
  47. kTextEncodingMacOriya = 12,
  48. kTextEncodingMacBengali = 13,
  49. kTextEncodingMacTamil = 14,
  50. kTextEncodingMacTelugu = 15,
  51. kTextEncodingMacKannada = 16,
  52. kTextEncodingMacMalayalam = 17,
  53. kTextEncodingMacSinhalese = 18,
  54. kTextEncodingMacBurmese = 19,
  55. kTextEncodingMacKhmer = 20,
  56. kTextEncodingMacThai = 21,
  57. kTextEncodingMacLaotian = 22,
  58. kTextEncodingMacGeorgian = 23,
  59. kTextEncodingMacArmenian = 24,
  60. kTextEncodingMacChineseSimp = 25,
  61. kTextEncodingMacTibetan = 26,
  62. kTextEncodingMacMongolian = 27,
  63. kTextEncodingMacEthiopic = 28,
  64. kTextEncodingMacCentralEurRoman = 29,
  65. kTextEncodingMacVietnamese = 30,
  66. kTextEncodingMacExtArabic = 31, /* The following use script code 0, smRoman*/
  67. kTextEncodingMacSymbol = 33,
  68. kTextEncodingMacDingbats = 34,
  69. kTextEncodingMacTurkish = 35,
  70. kTextEncodingMacCroatian = 36,
  71. kTextEncodingMacIcelandic = 37,
  72. kTextEncodingMacRomanian = 38,
  73. kTextEncodingMacCeltic = 39,
  74. kTextEncodingMacGaelic = 40,
  75. kTextEncodingMacKeyboardGlyphs = 41
  76. };
  77. /* The following are older names for backward compatibility*/
  78. enum {
  79. kTextEncodingMacTradChinese = kTextEncodingMacChineseTrad,
  80. kTextEncodingMacRSymbol = 8,
  81. kTextEncodingMacSimpChinese = kTextEncodingMacChineseSimp,
  82. kTextEncodingMacGeez = kTextEncodingMacEthiopic,
  83. kTextEncodingMacEastEurRoman = kTextEncodingMacCentralEurRoman,
  84. kTextEncodingMacUninterp = 32
  85. };
  86. /*
  87. Beginning in Mac OS 8.5, the following meta-value is used to indicate Unicode in some parts
  88. of the Mac OS which previously only expected a Mac OS script code. In some of these places,
  89. only 7 bits are available to indicate encoding (script code), so kTextEncodingUnicodeDefault
  90. cannot be used. For example, kTextEncodingMacUnicode can be used to indicate Unicode in the
  91. 7-bit script code field of a Unicode input method's ComponentDescription.componentFlags field;
  92. it can also be used to indicate Unicode in the 16-bit script code field of an AppleEvent's
  93. typeIntlWritingCode text tag.
  94. */
  95. enum {
  96. kTextEncodingMacUnicode = 0x7E /* Meta-value, Unicode as a Mac encoding*/
  97. };
  98. /* Variant Mac OS encodings that use script codes other than 0*/
  99. enum {
  100. /* The following use script code 4, smArabic*/
  101. kTextEncodingMacFarsi = 0x8C, /* Like MacArabic but uses Farsi digits*/
  102. /* The following use script code 7, smCyrillic*/
  103. kTextEncodingMacUkrainian = 0x98, /* Meta-value in TEC 1.5 & later; maps to kTextEncodingMacCyrillic variant */
  104. /* The following use script code 28, smEthiopic*/
  105. kTextEncodingMacInuit = 0xEC, /* The following use script code 32, smUnimplemented*/
  106. kTextEncodingMacVT100 = 0xFC /* VT100/102 font from Comm Toolbox: Latin-1 repertoire + box drawing etc*/
  107. };
  108. /* Special Mac OS encodings*/
  109. enum {
  110. kTextEncodingMacHFS = 0xFF /* Meta-value, should never appear in a table.*/
  111. };
  112. /* Unicode & ISO UCS encodings begin at 0x100*/
  113. enum {
  114. kTextEncodingUnicodeDefault = 0x0100, /* Meta-value, should never appear in a table.*/
  115. kTextEncodingUnicodeV1_1 = 0x0101,
  116. kTextEncodingISO10646_1993 = 0x0101, /* Code points identical to Unicode 1.1*/
  117. kTextEncodingUnicodeV2_0 = 0x0103, /* New location for Korean Hangul*/
  118. kTextEncodingUnicodeV2_1 = 0x0103, /* We treat both Unicode 2.0 and Unicode 2.1 as 2.1*/
  119. kTextEncodingUnicodeV3_0 = 0x0104,
  120. kTextEncodingUnicodeV3_1 = 0x0105, /* Adds characters requiring surrogate pairs in UTF-16*/
  121. kTextEncodingUnicodeV3_2 = 0x0106
  122. };
  123. /* ISO 8-bit and 7-bit encodings begin at 0x200*/
  124. enum {
  125. kTextEncodingISOLatin1 = 0x0201, /* ISO 8859-1*/
  126. kTextEncodingISOLatin2 = 0x0202, /* ISO 8859-2*/
  127. kTextEncodingISOLatin3 = 0x0203, /* ISO 8859-3*/
  128. kTextEncodingISOLatin4 = 0x0204, /* ISO 8859-4*/
  129. kTextEncodingISOLatinCyrillic = 0x0205, /* ISO 8859-5*/
  130. kTextEncodingISOLatinArabic = 0x0206, /* ISO 8859-6, = ASMO 708, =DOS CP 708*/
  131. kTextEncodingISOLatinGreek = 0x0207, /* ISO 8859-7*/
  132. kTextEncodingISOLatinHebrew = 0x0208, /* ISO 8859-8*/
  133. kTextEncodingISOLatin5 = 0x0209, /* ISO 8859-9*/
  134. kTextEncodingISOLatin6 = 0x020A, /* ISO 8859-10 */
  135. kTextEncodingISOLatin7 = 0x020D, /* ISO 8859-13, Baltic Rim */
  136. kTextEncodingISOLatin8 = 0x020E, /* ISO 8859-14, Celtic */
  137. kTextEncodingISOLatin9 = 0x020F /* ISO 8859-15, 8859-1 changed for EURO & CP1252 letters */
  138. };
  139. /* MS-DOS & Windows encodings begin at 0x400*/
  140. enum {
  141. kTextEncodingDOSLatinUS = 0x0400, /* code page 437*/
  142. kTextEncodingDOSGreek = 0x0405, /* code page 737 (formerly code page 437G)*/
  143. kTextEncodingDOSBalticRim = 0x0406, /* code page 775*/
  144. kTextEncodingDOSLatin1 = 0x0410, /* code page 850, "Multilingual"*/
  145. kTextEncodingDOSGreek1 = 0x0411, /* code page 851*/
  146. kTextEncodingDOSLatin2 = 0x0412, /* code page 852, Slavic*/
  147. kTextEncodingDOSCyrillic = 0x0413, /* code page 855, IBM Cyrillic*/
  148. kTextEncodingDOSTurkish = 0x0414, /* code page 857, IBM Turkish*/
  149. kTextEncodingDOSPortuguese = 0x0415, /* code page 860*/
  150. kTextEncodingDOSIcelandic = 0x0416, /* code page 861*/
  151. kTextEncodingDOSHebrew = 0x0417, /* code page 862*/
  152. kTextEncodingDOSCanadianFrench = 0x0418, /* code page 863*/
  153. kTextEncodingDOSArabic = 0x0419, /* code page 864*/
  154. kTextEncodingDOSNordic = 0x041A, /* code page 865*/
  155. kTextEncodingDOSRussian = 0x041B, /* code page 866*/
  156. kTextEncodingDOSGreek2 = 0x041C, /* code page 869, IBM Modern Greek*/
  157. kTextEncodingDOSThai = 0x041D, /* code page 874, also for Windows*/
  158. kTextEncodingDOSJapanese = 0x0420, /* code page 932, also for Windows; Shift-JIS with additions*/
  159. kTextEncodingDOSChineseSimplif = 0x0421, /* code page 936, also for Windows; was EUC-CN, now GBK (EUC-CN extended)*/
  160. kTextEncodingDOSKorean = 0x0422, /* code page 949, also for Windows; Unified Hangul Code (EUC-KR extended)*/
  161. kTextEncodingDOSChineseTrad = 0x0423, /* code page 950, also for Windows; Big-5*/
  162. kTextEncodingWindowsLatin1 = 0x0500, /* code page 1252*/
  163. kTextEncodingWindowsANSI = 0x0500, /* code page 1252 (alternate name)*/
  164. kTextEncodingWindowsLatin2 = 0x0501, /* code page 1250, Central Europe*/
  165. kTextEncodingWindowsCyrillic = 0x0502, /* code page 1251, Slavic Cyrillic*/
  166. kTextEncodingWindowsGreek = 0x0503, /* code page 1253*/
  167. kTextEncodingWindowsLatin5 = 0x0504, /* code page 1254, Turkish*/
  168. kTextEncodingWindowsHebrew = 0x0505, /* code page 1255*/
  169. kTextEncodingWindowsArabic = 0x0506, /* code page 1256*/
  170. kTextEncodingWindowsBalticRim = 0x0507, /* code page 1257*/
  171. kTextEncodingWindowsVietnamese = 0x0508, /* code page 1258*/
  172. kTextEncodingWindowsKoreanJohab = 0x0510 /* code page 1361, for Windows NT*/
  173. };
  174. /* Various national standards begin at 0x600*/
  175. enum {
  176. kTextEncodingUS_ASCII = 0x0600,
  177. kTextEncodingJIS_X0201_76 = 0x0620, /* JIS Roman and 1-byte katakana (halfwidth)*/
  178. kTextEncodingJIS_X0208_83 = 0x0621,
  179. kTextEncodingJIS_X0208_90 = 0x0622,
  180. kTextEncodingJIS_X0212_90 = 0x0623,
  181. kTextEncodingJIS_C6226_78 = 0x0624,
  182. kTextEncodingShiftJIS_X0213_00 = 0x0628, /* Shift-JIS format encoding of JIS X0213 planes 1 and 2*/
  183. kTextEncodingGB_2312_80 = 0x0630,
  184. kTextEncodingGBK_95 = 0x0631, /* annex to GB 13000-93; for Windows 95; EUC-CN extended*/
  185. kTextEncodingGB_18030_2000 = 0x0632,
  186. kTextEncodingKSC_5601_87 = 0x0640, /* same as KSC 5601-92 without Johab annex*/
  187. kTextEncodingKSC_5601_92_Johab = 0x0641, /* KSC 5601-92 Johab annex*/
  188. kTextEncodingCNS_11643_92_P1 = 0x0651, /* CNS 11643-1992 plane 1*/
  189. kTextEncodingCNS_11643_92_P2 = 0x0652, /* CNS 11643-1992 plane 2*/
  190. kTextEncodingCNS_11643_92_P3 = 0x0653 /* CNS 11643-1992 plane 3 (was plane 14 in 1986 version)*/
  191. };
  192. /* ISO 2022 collections begin at 0x800*/
  193. enum {
  194. kTextEncodingISO_2022_JP = 0x0820, /* RFC 1468*/
  195. kTextEncodingISO_2022_JP_2 = 0x0821, /* RFC 1554*/
  196. kTextEncodingISO_2022_JP_1 = 0x0822, /* RFC 2237*/
  197. kTextEncodingISO_2022_JP_3 = 0x0823, /* JIS X0213*/
  198. kTextEncodingISO_2022_CN = 0x0830,
  199. kTextEncodingISO_2022_CN_EXT = 0x0831,
  200. kTextEncodingISO_2022_KR = 0x0840
  201. };
  202. /* EUC collections begin at 0x900*/
  203. enum {
  204. kTextEncodingEUC_JP = 0x0920, /* ISO 646, 1-byte katakana, JIS 208, JIS 212*/
  205. kTextEncodingEUC_CN = 0x0930, /* ISO 646, GB 2312-80*/
  206. kTextEncodingEUC_TW = 0x0931, /* ISO 646, CNS 11643-1992 Planes 1-16*/
  207. kTextEncodingEUC_KR = 0x0940 /* ISO 646, KS C 5601-1987*/
  208. };
  209. /* Misc standards begin at 0xA00*/
  210. enum {
  211. kTextEncodingShiftJIS = 0x0A01, /* plain Shift-JIS*/
  212. kTextEncodingKOI8_R = 0x0A02, /* Russian internet standard*/
  213. kTextEncodingBig5 = 0x0A03, /* Big-5 (has variants)*/
  214. kTextEncodingMacRomanLatin1 = 0x0A04, /* Mac OS Roman permuted to align with ISO Latin-1*/
  215. kTextEncodingHZ_GB_2312 = 0x0A05, /* HZ (RFC 1842, for Chinese mail & news)*/
  216. kTextEncodingBig5_HKSCS_1999 = 0x0A06 /* Big-5 with Hong Kong special char set supplement*/
  217. };
  218. /* Other platform encodings*/
  219. enum {
  220. kTextEncodingNextStepLatin = 0x0B01, /* NextStep Latin encoding*/
  221. kTextEncodingNextStepJapanese = 0x0B02 /* NextStep Japanese encoding (variant of EUC-JP)*/
  222. };
  223. /* EBCDIC & IBM host encodings begin at 0xC00*/
  224. enum {
  225. kTextEncodingEBCDIC_US = 0x0C01, /* basic EBCDIC-US*/
  226. kTextEncodingEBCDIC_CP037 = 0x0C02 /* code page 037, extended EBCDIC (Latin-1 set) for US,Canada...*/
  227. };
  228. /* Special values*/
  229. enum {
  230. kTextEncodingMultiRun = 0x0FFF, /* Multi-encoding text with external run info*/
  231. kTextEncodingUnknown = 0xFFFF /* Unknown or unspecified */
  232. };
  233. /* TextEncodingVariant type & values */
  234. typedef UInt32 TextEncodingVariant;
  235. /* Default TextEncodingVariant, for any TextEncodingBase*/
  236. enum {
  237. kTextEncodingDefaultVariant = 0
  238. };
  239. /* Variants of kTextEncodingMacRoman */
  240. enum {
  241. kMacRomanDefaultVariant = 0, /* meta value, maps to 1 or 2 depending on System */
  242. kMacRomanCurrencySignVariant = 1, /* Mac OS version < 8.5, 0xDB is CURRENCY SIGN*/
  243. kMacRomanEuroSignVariant = 2 /* Mac OS version >= 8.5, 0xDB is EURO SIGN */
  244. };
  245. /* Variants of kTextEncodingMacCyrillic (for TEC 1.5 and later) */
  246. enum {
  247. kMacCyrillicDefaultVariant = 0, /* meta value, maps to 1, 2, or 3 depending on System*/
  248. kMacCyrillicCurrSignStdVariant = 1, /* Mac OS < 9.0 (RU,BG), 0xFF = CURRENCY SIGN, 0xA2/0xB6 = CENT / PARTIAL DIFF.*/
  249. kMacCyrillicCurrSignUkrVariant = 2, /* Mac OS < 9.0 (UA,LangKit), 0xFF = CURRENCY SIGN, 0xA2/0xB6 = GHE WITH UPTURN*/
  250. kMacCyrillicEuroSignVariant = 3 /* Mac OS >= 9.0, 0xFF is EURO SIGN, 0xA2/0xB6 = GHE WITH UPTURN*/
  251. };
  252. /* Variants of kTextEncodingMacIcelandic */
  253. enum {
  254. kMacIcelandicStdDefaultVariant = 0, /* meta value, maps to 2 or 4 depending on System */
  255. kMacIcelandicTTDefaultVariant = 1, /* meta value, maps to 3 or 5 depending on System */
  256. /* The following are for Mac OS version < 8.5, 0xDB is CURRENCY SIGN */
  257. kMacIcelandicStdCurrSignVariant = 2, /* 0xBB/0xBC are fem./masc. ordinal indicators*/
  258. kMacIcelandicTTCurrSignVariant = 3, /* 0xBB/0xBC are fi/fl ligatures*/
  259. /* The following are for Mac OS version >= 8.5, 0xDB is EURO SIGN */
  260. kMacIcelandicStdEuroSignVariant = 4, /* 0xBB/0xBC are fem./masc. ordinal indicators*/
  261. kMacIcelandicTTEuroSignVariant = 5 /* 0xBB/0xBC are fi/fl ligatures*/
  262. };
  263. /* Variants of kTextEncodingMacCroatian */
  264. enum {
  265. kMacCroatianDefaultVariant = 0, /* meta value, maps to 1 or 2 depending on System */
  266. kMacCroatianCurrencySignVariant = 1, /* Mac OS version < 8.5, 0xDB is CURRENCY SIGN */
  267. kMacCroatianEuroSignVariant = 2 /* Mac OS version >= 8.5, 0xDB is EURO SIGN */
  268. };
  269. /* Variants of kTextEncodingMacRomanian */
  270. enum {
  271. kMacRomanianDefaultVariant = 0, /* meta value, maps to 1 or 2 depending on System */
  272. kMacRomanianCurrencySignVariant = 1, /* Mac OS version < 8.5, 0xDB is CURRENCY SIGN */
  273. kMacRomanianEuroSignVariant = 2 /* Mac OS version >= 8.5, 0xDB is EURO SIGN */
  274. };
  275. /* Variants of kTextEncodingMacJapanese*/
  276. enum {
  277. kMacJapaneseStandardVariant = 0,
  278. kMacJapaneseStdNoVerticalsVariant = 1,
  279. kMacJapaneseBasicVariant = 2,
  280. kMacJapanesePostScriptScrnVariant = 3,
  281. kMacJapanesePostScriptPrintVariant = 4,
  282. kMacJapaneseVertAtKuPlusTenVariant = 5
  283. };
  284. /* Variants of kTextEncodingMacArabic*/
  285. enum {
  286. kMacArabicStandardVariant = 0, /* 0xC0 is 8-spoke asterisk, 0x2A & 0xAA are asterisk (e.g. Cairo)*/
  287. kMacArabicTrueTypeVariant = 1, /* 0xC0 is asterisk, 0x2A & 0xAA are multiply signs (e.g. Baghdad)*/
  288. kMacArabicThuluthVariant = 2, /* 0xC0 is Arabic five-point star, 0x2A & 0xAA are multiply signs*/
  289. kMacArabicAlBayanVariant = 3 /* 8-spoke asterisk, multiply sign, Koranic ligatures & parens*/
  290. };
  291. /* Variants of kTextEncodingMacFarsi*/
  292. enum {
  293. kMacFarsiStandardVariant = 0, /* 0xC0 is 8-spoke asterisk, 0x2A & 0xAA are asterisk (e.g. Tehran)*/
  294. kMacFarsiTrueTypeVariant = 1 /* asterisk, multiply signs, Koranic ligatures, geometric shapes*/
  295. };
  296. /* Variants of kTextEncodingMacHebrew*/
  297. enum {
  298. kMacHebrewStandardVariant = 0,
  299. kMacHebrewFigureSpaceVariant = 1
  300. };
  301. /* Variants of kTextEncodingMacVT100 */
  302. enum {
  303. kMacVT100DefaultVariant = 0, /* meta value, maps to 1 or 2 depending on System */
  304. kMacVT100CurrencySignVariant = 1, /* Mac OS version < 8.5, 0xDB is CURRENCY SIGN */
  305. kMacVT100EuroSignVariant = 2 /* Mac OS version >= 8.5, 0xDB is EURO SIGN */
  306. };
  307. /* Variants of Unicode & ISO 10646 encodings*/
  308. enum {
  309. kUnicodeNoSubset = 0,
  310. kUnicodeCanonicalDecompVariant = 2, /* canonical decomposition (NFD); excludes composed characters*/
  311. kUnicodeCanonicalCompVariant = 3, /* canonical composition (NFC); uses the composed chars as of Unicode 3.1*/
  312. kUnicodeHFSPlusDecompVariant = 8, /* decomposition for HFS+; doesn't decompose in 2000-2FFF, F900-FAFF, 2F800-2FAFF*/
  313. kUnicodeHFSPlusCompVariant = 9 /* composition based on HFS+ decomposition*/
  314. };
  315. /* Variants of Big-5 encoding*/
  316. enum {
  317. kBig5_BasicVariant = 0,
  318. kBig5_StandardVariant = 1, /* 0xC6A1-0xC7FC: kana, Cyrillic, enclosed numerics*/
  319. kBig5_ETenVariant = 2 /* adds kana, Cyrillic, radicals, etc with hi bytes C6-C8,F9*/
  320. };
  321. /* Variants of MacRomanLatin1 */
  322. enum {
  323. kMacRomanLatin1DefaultVariant = 0, /* meta value, maps to others depending on System*/
  324. kMacRomanLatin1StandardVariant = 2, /* permuted MacRoman, EuroSignVariant*/
  325. kMacRomanLatin1TurkishVariant = 6, /* permuted MacTurkish*/
  326. kMacRomanLatin1CroatianVariant = 8, /* permuted MacCroatian, EuroSignVariant*/
  327. kMacRomanLatin1IcelandicVariant = 11, /* permuted MacIcelandic, StdEuroSignVariant*/
  328. kMacRomanLatin1RomanianVariant = 14 /* permuted MacRomanian, EuroSignVariant*/
  329. };
  330. /* Unicode variants not yet supported (and not fully defined)*/
  331. enum {
  332. kUnicodeNoCompatibilityVariant = 1,
  333. kUnicodeNoCorporateVariant = 4
  334. };
  335. /* The following are older names for backward compatibility*/
  336. enum {
  337. kMacRomanStandardVariant = 0,
  338. kMacIcelandicStandardVariant = 0,
  339. kMacIcelandicTrueTypeVariant = 1,
  340. kJapaneseStandardVariant = 0,
  341. kJapaneseStdNoVerticalsVariant = 1,
  342. kJapaneseBasicVariant = 2,
  343. kJapanesePostScriptScrnVariant = 3,
  344. kJapanesePostScriptPrintVariant = 4,
  345. kJapaneseVertAtKuPlusTenVariant = 5, /* kJapaneseStdNoOneByteKanaVariant = 6, // replaced by kJapaneseNoOneByteKanaOption*/
  346. /* kJapaneseBasicNoOneByteKanaVariant = 7, // replaced by kJapaneseNoOneByteKanaOption */
  347. kHebrewStandardVariant = 0,
  348. kHebrewFigureSpaceVariant = 1,
  349. kUnicodeMaxDecomposedVariant = 2, /* replaced by kUnicodeCanonicalDecompVariant*/
  350. kUnicodeNoComposedVariant = 3, /* this really meant NoComposing; replaced by kUnicodeCanonicalCompVariant*/
  351. /* The following Japanese variant options were never supported and are now deprecated.*/
  352. /* In TEC 1.4 and later their functionality is replaced by the Unicode Converter options listed.*/
  353. kJapaneseNoOneByteKanaOption = 0x20, /* replaced by UnicodeConverter option kUnicodeNoHalfwidthCharsBit*/
  354. kJapaneseUseAsciiBackslashOption = 0x40 /* replaced by UnicodeConverter option kUnicodeForceASCIIRangeBit*/
  355. };
  356. /* TextEncodingFormat type & values */
  357. typedef UInt32 TextEncodingFormat;
  358. enum {
  359. /* Default TextEncodingFormat for any TextEncodingBase*/
  360. kTextEncodingDefaultFormat = 0, /* Formats for Unicode & ISO 10646*/
  361. kUnicode16BitFormat = 0,
  362. kUnicodeUTF7Format = 1,
  363. kUnicodeUTF8Format = 2,
  364. kUnicode32BitFormat = 3, /* New constants since 10.3?*/
  365. kUnicodeUTF16Format = 0, /* UTF16 form (16-bit units), native or external byte order (see below)*/
  366. kUnicodeUTF32Format = 3, /* UTF32 form (32-bit units), native or external byte order (see below)*/
  367. kUnicodeUTF16BEFormat = 4, /* UTF16 form, explicit big-endian byte order, no BOM*/
  368. kUnicodeUTF16LEFormat = 5, /* UTF16 form, explicit little-endian byte order, no BOM*/
  369. kUnicodeUTF32BEFormat = 6, /* UTF32 form, explicit big-endian byte order, no BOM*/
  370. kUnicodeUTF32LEFormat = 7, /* UTF32 form, explicit little-endian byte order, no BOM*/
  371. kUnicodeSCSUFormat = 8 /* Std. Compression Scheme for Unicode, Unicode Tech Std. #6*/
  372. };
  373. /*
  374. Note for kUnicodeUTF16Format and kUnicodeUTF32Format:
  375. - An array of UTF16Char (UniChar) or UTF32Char is normally understood to use "internal" or
  376. platform-native byte ordering for kUnicodeUTF16Format and kUnicodeUTF32Format; the array MAY
  377. begin with byte-order mark (BOM), but the BOM should match the internal ordering.
  378. - If an array of bytes (such as char *) that can be in various encodings is specified to be
  379. in Unicode with kUnicodeUTF16Format or kUnicodeUTF32Format (not explicitly BE or LE), then it
  380. is assumed to use "external" byte ordering, which means: If there is a BOM at the beginning
  381. of text, the BOM specifies the byte ordering, otherwise big-endian is assumed.
  382. Synonyms for some Unicode formats
  383. */
  384. /* TextEncoding type */
  385. typedef UInt32 TextEncoding;
  386. /* name part selector for GetTextEncodingName*/
  387. typedef UInt32 TextEncodingNameSelector;
  388. enum {
  389. kTextEncodingFullName = 0,
  390. kTextEncodingBaseName = 1,
  391. kTextEncodingVariantName = 2,
  392. kTextEncodingFormatName = 3
  393. };
  394. /* Types used in conversion */
  395. struct TextEncodingRun {
  396. ByteOffset offset;
  397. TextEncoding textEncoding;
  398. };
  399. typedef struct TextEncodingRun TextEncodingRun;
  400. typedef TextEncodingRun * TextEncodingRunPtr;
  401. typedef const TextEncodingRun * ConstTextEncodingRunPtr;
  402. struct ScriptCodeRun {
  403. ByteOffset offset;
  404. ScriptCode script;
  405. };
  406. typedef struct ScriptCodeRun ScriptCodeRun;
  407. typedef ScriptCodeRun * ScriptCodeRunPtr;
  408. typedef const ScriptCodeRun * ConstScriptCodeRunPtr;
  409. typedef UInt8 * TextPtr;
  410. typedef const UInt8 * ConstTextPtr;
  411. /* Basic types for Unicode characters and strings:*/
  412. typedef UniChar * UniCharArrayPtr;
  413. typedef const UniChar * ConstUniCharArrayPtr;
  414. /*
  415. UniCharArrayHandle is a handle type to correspond to UniCharArrayPtr,
  416. i.e. a handle to an array of UniChars (UInt16s).
  417. */
  418. typedef UniCharArrayPtr * UniCharArrayHandle;
  419. /*
  420. UniCharArrayOffset is used to indicate an edge offset in an array
  421. of UniChars (UInt16s).
  422. */
  423. typedef UInt32 UniCharArrayOffset;
  424. /* enums for TextEncoding Conversion routines*/
  425. enum {
  426. kTextScriptDontCare = -128,
  427. kTextLanguageDontCare = -128,
  428. kTextRegionDontCare = -128
  429. };
  430. /* struct for TECGetInfo*/
  431. struct TECInfo {
  432. UInt16 format; /* format code for this struct*/
  433. UInt16 tecVersion; /* TEC version in BCD, e.g. 0x0121 for 1.2.1*/
  434. UInt32 tecTextConverterFeatures; /* bitmask indicating TEC features/fixes*/
  435. UInt32 tecUnicodeConverterFeatures; /* bitmask indicating UnicodeConverter features/fixes*/
  436. UInt32 tecTextCommonFeatures; /* bitmask indicating TextCommon features/fixes*/
  437. Str31 tecTextEncodingsFolderName; /* localized name of Text Encodings folder (pascal string)*/
  438. Str31 tecExtensionFileName; /* localized name of TEC extension (pascal string)*/
  439. UInt16 tecLowestTEFileVersion; /* Lowest version (BCD) of all files in Text Encodings folder*/
  440. UInt16 tecHighestTEFileVersion; /* Highest version (BCD) of all files in Text Encodings folder*/
  441. };
  442. typedef struct TECInfo TECInfo;
  443. typedef TECInfo * TECInfoPtr;
  444. typedef TECInfoPtr * TECInfoHandle;
  445. /* Value for TECInfo format code*/
  446. enum {
  447. kTECInfoCurrentFormat = 2 /* any future formats will just add fields at the end*/
  448. };
  449. /*
  450. Defined feature/fix bits for tecUnicodeConverterFeatures field
  451. Bit: Meaning if set:
  452. ---- ---------------
  453. kTECKeepInfoFixBit Unicode Converter no longer ignores other control flags if
  454. kUnicodeKeepInfoBit is set. Bug fix in TEC Manager 1.2.1.
  455. kTECFallbackTextLengthFixBit Unicode Converter honors the *srcConvLen and *destConvLen
  456. returned by caller-supplied fallback handler for any status it
  457. returns except for kTECUnmappableElementErr (previously it only
  458. honored these values if noErr was returned). Bug fix in TEC
  459. Manager 1.2.1.
  460. kTECTextRunBitClearFixBit ConvertFromUnicodeToTextRun & ConvertFromUnicodeToScriptCodeRun
  461. function correctly if the kUnicodeTextRunBit is set (previously
  462. their determination of best target encoding was incorrect). Bug
  463. fix in TEC Manager 1.3.
  464. kTECTextToUnicodeScanFixBit ConvertFromTextToUnicode uses an improved scanner and maintains
  465. some resulting state information, which it uses for mapping.
  466. This has several effects:
  467. - Improved mapping of 0x30-0x39 digits in Mac OS Arabic, fewer
  468. direction overrides when mapping Mac OS Arabic & Hebrew, and
  469. improved mapping of certain characters in Indic encodings.
  470. - Malformed input produces kTextMalformedInputErr.
  471. - ConvertFromTextToUnicode accepts and uses the control flags
  472. kUnicodeKeepInfoMask and kUnicodeStringUnterminatedMask.
  473. Bug fix and enhancement in TEC Manager 1.3.
  474. kTECAddForceASCIIChangesBit Define new control flag bits kUnicodeForceASCIIRangeBit and
  475. kUnicodeNoHalfwidthCharsBit for use with
  476. ConvertFromTextToUnicode, ConvertFromUnicodeToText, etc.
  477. Enhancement in TEC Manager 1.4.
  478. kTECPreferredEncodingFixBit CreateUnicodeToTextRunInfo and related functions fix a problem
  479. that occurred when a preferred encoding was specified that did
  480. not match the System script; the preferred script was not
  481. actually placed first in the ordered list of encodings to use.
  482. Bug fix in TEC Manager 1.4.
  483. kTECAddTextRunHeuristicsBit Define new control flag bit kUnicodeTextRunHeuristicsBit for
  484. use with ConvertFromUnicodeToTextRun.
  485. kTECAddFallbackInterruptBit Define new option kUnicodeFallbackInterruptSafeMask for use
  486. with SetFallbackUnicodeToText. If a client fallback handler is
  487. installed without specifying this bit, ConvertFromUnicodeToText
  488. will HLock the tables it uses (in case the fallback handler
  489. moves memory); otherwise, it won't.
  490. */
  491. enum {
  492. kTECKeepInfoFixBit = 0,
  493. kTECFallbackTextLengthFixBit = 1,
  494. kTECTextRunBitClearFixBit = 2,
  495. kTECTextToUnicodeScanFixBit = 3,
  496. kTECAddForceASCIIChangesBit = 4,
  497. kTECPreferredEncodingFixBit = 5,
  498. kTECAddTextRunHeuristicsBit = 6,
  499. kTECAddFallbackInterruptBit = 7
  500. };
  501. enum {
  502. kTECKeepInfoFixMask = 1L << kTECKeepInfoFixBit,
  503. kTECFallbackTextLengthFixMask = 1L << kTECFallbackTextLengthFixBit,
  504. kTECTextRunBitClearFixMask = 1L << kTECTextRunBitClearFixBit,
  505. kTECTextToUnicodeScanFixMask = 1L << kTECTextToUnicodeScanFixBit,
  506. kTECAddForceASCIIChangesMask = 1L << kTECAddForceASCIIChangesBit,
  507. kTECPreferredEncodingFixMask = 1L << kTECPreferredEncodingFixBit,
  508. kTECAddTextRunHeuristicsMask = 1L << kTECAddTextRunHeuristicsBit,
  509. kTECAddFallbackInterruptMask = 1L << kTECAddFallbackInterruptBit
  510. };
  511. /*
  512. -------------------------------------------------------------------------------------------------
  513. CONSTANTS for common and special Unicode code values
  514. -------------------------------------------------------------------------------------------------
  515. */
  516. enum {
  517. kUnicodeByteOrderMark = 0xFEFF,
  518. kUnicodeObjectReplacement = 0xFFFC, /* placeholder for non-text object*/
  519. kUnicodeReplacementChar = 0xFFFD, /* Unicode replacement for unconvertable input char*/
  520. kUnicodeSwappedByteOrderMark = 0xFFFE, /* not a Unicode char; byte-swapped version of FEFF*/
  521. kUnicodeNotAChar = 0xFFFF /* not a Unicode char; may be used as a terminator*/
  522. };
  523. /*
  524. -------------------------------------------------------------------------------------------------
  525. CONSTANTS & DATA STRUCTURES for Unicode Properties
  526. -------------------------------------------------------------------------------------------------
  527. */
  528. typedef SInt32 UCCharPropertyType;
  529. enum {
  530. kUCCharPropTypeGenlCategory = 1, /* requests enumeration value*/
  531. kUCCharPropTypeCombiningClass = 2, /* requests numeric value 0..255*/
  532. kUCCharPropTypeBidiCategory = 3 /* requests enumeration value*/
  533. };
  534. typedef UInt32 UCCharPropertyValue;
  535. /* General Category enumeration values (requested by kUCCharPropTypeGenlCategory)*/
  536. enum {
  537. /* Normative categories:*/
  538. kUCGenlCatOtherNotAssigned = 0, /* Cn Other, Not Assigned*/
  539. kUCGenlCatOtherControl = 1, /* Cc Other, Control*/
  540. kUCGenlCatOtherFormat = 2, /* Cf Other, Format*/
  541. kUCGenlCatOtherSurrogate = 3, /* Cs Other, Surrogate*/
  542. kUCGenlCatOtherPrivateUse = 4, /* Co Other, Private Use*/
  543. kUCGenlCatMarkNonSpacing = 5, /* Mn Mark, Non-Spacing*/
  544. kUCGenlCatMarkSpacingCombining = 6, /* Mc Mark, Spacing Combining*/
  545. kUCGenlCatMarkEnclosing = 7, /* Me Mark, Enclosing*/
  546. kUCGenlCatNumberDecimalDigit = 8, /* Nd Number, Decimal Digit*/
  547. kUCGenlCatNumberLetter = 9, /* Nl Number, Letter*/
  548. kUCGenlCatNumberOther = 10, /* No Number, Other*/
  549. kUCGenlCatSeparatorSpace = 11, /* Zs Separator, Space*/
  550. kUCGenlCatSeparatorLine = 12, /* Zl Separator, Line*/
  551. kUCGenlCatSeparatorParagraph = 13, /* Zp Separator, Paragraph*/
  552. kUCGenlCatLetterUppercase = 14, /* Lu Letter, Uppercase*/
  553. kUCGenlCatLetterLowercase = 15, /* Ll Letter, Lowercase*/
  554. kUCGenlCatLetterTitlecase = 16, /* Lt Letter, Titlecase*/
  555. /* Informative categories:*/
  556. kUCGenlCatLetterModifier = 17, /* Lm Letter, Modifier*/
  557. kUCGenlCatLetterOther = 18, /* Lo Letter, Other*/
  558. kUCGenlCatPunctConnector = 20, /* Pc Punctuation, Connector*/
  559. kUCGenlCatPunctDash = 21, /* Pd Punctuation, Dash*/
  560. kUCGenlCatPunctOpen = 22, /* Ps Punctuation, Open*/
  561. kUCGenlCatPunctClose = 23, /* Pe Punctuation, Close*/
  562. kUCGenlCatPunctInitialQuote = 24, /* Pi Punctuation, Initial quote*/
  563. kUCGenlCatPunctFinalQuote = 25, /* Pf Punctuation, Final quote*/
  564. kUCGenlCatPunctOther = 26, /* Po Punctuation, Other*/
  565. kUCGenlCatSymbolMath = 28, /* Sm Symbol, Math*/
  566. kUCGenlCatSymbolCurrency = 29, /* Sc Symbol, Currency*/
  567. kUCGenlCatSymbolModifier = 30, /* Sk Symbol, Modifier*/
  568. kUCGenlCatSymbolOther = 31 /* So Symbol, Other*/
  569. };
  570. /* Bidirectional Category enumeration values (requested by kUCCharPropTypeBidiCategory)*/
  571. enum {
  572. kUCBidiCatNotApplicable = 0, /* for now use this for unassigned*/
  573. /* Strong types:*/
  574. kUCBidiCatLeftRight = 1, /* L Left-to-Right*/
  575. kUCBidiCatRightLeft = 2, /* R Right-to-Left*/
  576. /* Weak types:*/
  577. kUCBidiCatEuroNumber = 3, /* EN European Number*/
  578. kUCBidiCatEuroNumberSeparator = 4, /* ES European Number Separator*/
  579. kUCBidiCatEuroNumberTerminator = 5, /* ET European Number Terminator*/
  580. kUCBidiCatArabicNumber = 6, /* AN Arabic Number*/
  581. kUCBidiCatCommonNumberSeparator = 7, /* CS Common Number Separator*/
  582. /* Separators:*/
  583. kUCBidiCatBlockSeparator = 8, /* B Paragraph Separator (was Block Separator)*/
  584. kUCBidiCatSegmentSeparator = 9, /* S Segment Separator*/
  585. /* Neutrals:*/
  586. kUCBidiCatWhitespace = 10, /* WS Whitespace*/
  587. kUCBidiCatOtherNeutral = 11, /* ON Other Neutrals (unassigned codes could use this)*/
  588. /* New categories for Unicode 3.0*/
  589. kUCBidiCatRightLeftArabic = 12, /* AL Right-to-Left Arabic (was Arabic Letter)*/
  590. kUCBidiCatLeftRightEmbedding = 13, /* LRE Left-to-Right Embedding*/
  591. kUCBidiCatRightLeftEmbedding = 14, /* RLE Right-to-Left Embedding*/
  592. kUCBidiCatLeftRightOverride = 15, /* LRO Left-to-Right Override*/
  593. kUCBidiCatRightLeftOverride = 16, /* RLO Right-to-Left Override*/
  594. kUCBidiCatPopDirectionalFormat = 17, /* PDF Pop Directional Format*/
  595. kUCBidiCatNonSpacingMark = 18, /* NSM Non-Spacing Mark*/
  596. kUCBidiCatBoundaryNeutral = 19 /* BN Boundary Neutral*/
  597. };
  598. /*
  599. -------------------------------------------------------------------------------------------------
  600. Prototypes for TextEncoding functions
  601. -------------------------------------------------------------------------------------------------
  602. */
  603. /*
  604. * CreateTextEncoding()
  605. *
  606. * Availability:
  607. * Non-Carbon CFM: in TextCommon 1.1 and later
  608. * CarbonLib: in CarbonLib 1.0 and later
  609. * Mac OS X: in version 10.0 and later
  610. */
  611. EXTERN_API( TextEncoding )
  612. CreateTextEncoding(
  613. TextEncodingBase encodingBase,
  614. TextEncodingVariant encodingVariant,
  615. TextEncodingFormat encodingFormat);
  616. /*
  617. * GetTextEncodingBase()
  618. *
  619. * Availability:
  620. * Non-Carbon CFM: in TextCommon 1.1 and later
  621. * CarbonLib: in CarbonLib 1.0 and later
  622. * Mac OS X: in version 10.0 and later
  623. */
  624. EXTERN_API( TextEncodingBase )
  625. GetTextEncodingBase(TextEncoding encoding);
  626. /*
  627. * GetTextEncodingVariant()
  628. *
  629. * Availability:
  630. * Non-Carbon CFM: in TextCommon 1.1 and later
  631. * CarbonLib: in CarbonLib 1.0 and later
  632. * Mac OS X: in version 10.0 and later
  633. */
  634. EXTERN_API( TextEncodingVariant )
  635. GetTextEncodingVariant(TextEncoding encoding);
  636. /*
  637. * GetTextEncodingFormat()
  638. *
  639. * Availability:
  640. * Non-Carbon CFM: in TextCommon 1.1 and later
  641. * CarbonLib: in CarbonLib 1.0 and later
  642. * Mac OS X: in version 10.0 and later
  643. */
  644. EXTERN_API( TextEncodingFormat )
  645. GetTextEncodingFormat(TextEncoding encoding);
  646. /*
  647. * ResolveDefaultTextEncoding()
  648. *
  649. * Availability:
  650. * Non-Carbon CFM: in TextCommon 1.1 and later
  651. * CarbonLib: in CarbonLib 1.0 and later
  652. * Mac OS X: in version 10.0 and later
  653. */
  654. EXTERN_API( TextEncoding )
  655. ResolveDefaultTextEncoding(TextEncoding encoding);
  656. /*
  657. * GetTextEncodingName()
  658. *
  659. * Availability:
  660. * Non-Carbon CFM: in TextCommon 1.1 and later
  661. * CarbonLib: in CarbonLib 1.0 and later
  662. * Mac OS X: in version 10.0 and later
  663. */
  664. EXTERN_API_C( OSStatus )
  665. GetTextEncodingName(
  666. TextEncoding iEncoding,
  667. TextEncodingNameSelector iNamePartSelector,
  668. RegionCode iPreferredRegion,
  669. TextEncoding iPreferredEncoding,
  670. ByteCount iOutputBufLen,
  671. ByteCount * oNameLength,
  672. RegionCode * oActualRegion, /* can be NULL */
  673. TextEncoding * oActualEncoding, /* can be NULL */
  674. TextPtr oEncodingName);
  675. /*
  676. * TECGetInfo()
  677. *
  678. * Availability:
  679. * Non-Carbon CFM: in TextCommon 1.2.1 and later
  680. * CarbonLib: in CarbonLib 1.0 and later
  681. * Mac OS X: in version 10.0 and later
  682. */
  683. EXTERN_API( OSStatus )
  684. TECGetInfo(TECInfoHandle * tecInfo);
  685. /*
  686. * UpgradeScriptInfoToTextEncoding()
  687. *
  688. * Availability:
  689. * Non-Carbon CFM: in TextCommon 1.1 and later
  690. * CarbonLib: in CarbonLib 1.0 and later
  691. * Mac OS X: in version 10.0 and later
  692. */
  693. EXTERN_API( OSStatus )
  694. UpgradeScriptInfoToTextEncoding(
  695. ScriptCode iTextScriptID,
  696. LangCode iTextLanguageID,
  697. RegionCode iRegionID,
  698. ConstStr255Param iTextFontname,
  699. TextEncoding * oEncoding);
  700. /*
  701. * RevertTextEncodingToScriptInfo()
  702. *
  703. * Availability:
  704. * Non-Carbon CFM: in TextCommon 1.1 and later
  705. * CarbonLib: in CarbonLib 1.0 and later
  706. * Mac OS X: in version 10.0 and later
  707. */
  708. EXTERN_API( OSStatus )
  709. RevertTextEncodingToScriptInfo(
  710. TextEncoding iEncoding,
  711. ScriptCode * oTextScriptID,
  712. LangCode * oTextLanguageID, /* can be NULL */
  713. Str255 oTextFontname); /* can be NULL */
  714. /*
  715. * GetTextEncodingFromScriptInfo()
  716. *
  717. * Availability:
  718. * Non-Carbon CFM: not available
  719. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  720. * Mac OS X: in version 10.2 and later
  721. */
  722. EXTERN_API( OSStatus )
  723. GetTextEncodingFromScriptInfo(
  724. ScriptCode iTextScriptID,
  725. LangCode iTextLanguageID,
  726. RegionCode iTextRegionID,
  727. TextEncoding * oEncoding);
  728. /*
  729. * GetScriptInfoFromTextEncoding()
  730. *
  731. * Availability:
  732. * Non-Carbon CFM: not available
  733. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  734. * Mac OS X: in version 10.2 and later
  735. */
  736. EXTERN_API( OSStatus )
  737. GetScriptInfoFromTextEncoding(
  738. TextEncoding iEncoding,
  739. ScriptCode * oTextScriptID,
  740. LangCode * oTextLanguageID); /* can be NULL */
  741. /*
  742. * NearestMacTextEncodings()
  743. *
  744. * Availability:
  745. * Non-Carbon CFM: in TextCommon 1.5 and later
  746. * CarbonLib: in CarbonLib 1.0 and later
  747. * Mac OS X: in version 10.0 and later
  748. */
  749. EXTERN_API( OSStatus )
  750. NearestMacTextEncodings(
  751. TextEncoding generalEncoding,
  752. TextEncoding * bestMacEncoding,
  753. TextEncoding * alternateMacEncoding);
  754. /*
  755. * UCGetCharProperty()
  756. *
  757. * Availability:
  758. * Non-Carbon CFM: in TextCommon 1.5 and later
  759. * CarbonLib: in CarbonLib 1.0 and later
  760. * Mac OS X: in version 10.0 and later
  761. */
  762. EXTERN_API_C( OSStatus )
  763. UCGetCharProperty(
  764. const UniChar * charPtr,
  765. UniCharCount textLength,
  766. UCCharPropertyType propType,
  767. UCCharPropertyValue * propValue);
  768. /*
  769. -------------------------------------------------------------------------------------------------
  770. Surrogate pair utilities
  771. -------------------------------------------------------------------------------------------------
  772. */
  773. #if !defined(UC_INLINE)
  774. #if defined(__GNUC__)
  775. #define UC_INLINE static __inline__
  776. #elif defined(__MWERKS__) || defined(__cplusplus)
  777. #define UC_INLINE static inline
  778. #else
  779. #define UC_INLINE static
  780. #endif
  781. #endif
  782. // surrogate ranges
  783. enum {
  784. kUCHighSurrogateRangeStart = 0xD800UL,
  785. kUCHighSurrogateRangeEnd = 0xDBFFUL,
  786. kUCLowSurrogateRangeStart = 0xDC00UL,
  787. kUCLowSurrogateRangeEnd = 0xDFFFUL
  788. };
  789. /*!
  790. @function UCIsSurrogateHighCharacter
  791. Reports whether or not the character is a high surrogate.
  792. @param character The character to be checked.
  793. @result true, if character is a high surrogate, otherwise false.
  794. */
  795. UC_INLINE Boolean UCIsSurrogateHighCharacter( UniChar character ) {
  796. /* return ( ( character >= kUCHighSurrogateRangeStart ) && (character <= kUCHighSurrogateRangeEnd ) ? true : false ); */
  797. return ( ( character & 0xFC00UL ) == kUCHighSurrogateRangeStart );
  798. }
  799. /*!
  800. @function UCIsSurrogateLowCharacter
  801. Reports whether or not the character is a low surrogate.
  802. @param character The character to be checked.
  803. @result true, if character is a low surrogate, otherwise false.
  804. */
  805. UC_INLINE Boolean UCIsSurrogateLowCharacter( UniChar character ) {
  806. /* return ( ( character >= kUCLowSurrogateRangeStart ) && ( character <= kUCLowSurrogateRangeEnd ) ? true : false ); */
  807. return ( ( character & 0xFC00UL ) == kUCLowSurrogateRangeStart );
  808. }
  809. /*!
  810. @function UCGetUnicodeScalarValueForSurrogatePair
  811. Returns the UTF-32 value corresponding to the surrogate pair passed in.
  812. @param surrogateHigh The high surrogate character. If this parameter
  813. is not a valid high surrogate character, the behavior is undefined.
  814. @param surrogateLow The low surrogate character. If this parameter
  815. is not a valid low surrogate character, the behavior is undefined.
  816. @result The UTF-32 value for the surrogate pair.
  817. */
  818. UC_INLINE UnicodeScalarValue UCGetUnicodeScalarValueForSurrogatePair( UniChar surrogateHigh, UniChar surrogateLow ) {
  819. return ( ( surrogateHigh - kUCHighSurrogateRangeStart ) << 10 ) + ( surrogateLow - kUCLowSurrogateRangeStart ) + 0x0010000UL;
  820. }
  821. #if PRAGMA_STRUCT_ALIGN
  822. #pragma options align=reset
  823. #elif PRAGMA_STRUCT_PACKPUSH
  824. #pragma pack(pop)
  825. #elif PRAGMA_STRUCT_PACK
  826. #pragma pack()
  827. #endif
  828. #ifdef PRAGMA_IMPORT_OFF
  829. #pragma import off
  830. #elif PRAGMA_IMPORT
  831. #pragma import reset
  832. #endif
  833. #ifdef __cplusplus
  834. }
  835. #endif
  836. #endif /* __TEXTCOMMON__ */