TextCommon.pas 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196
  1. {
  2. File: CarbonCore/TextCommon.h
  3. Contains: TextEncoding-related types and constants, and prototypes for related functions
  4. Copyright: © 1995-2012 Apple Inc. All rights reserved.
  5. Bugs?: For bug reports, consult the following page on
  6. the World Wide Web:
  7. http://bugs.freepascal.org
  8. }
  9. {
  10. Modified for use with Free Pascal
  11. Version 308
  12. Please report any bugs to <[email protected]>
  13. }
  14. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  15. {$mode macpas}
  16. {$packenum 1}
  17. {$macro on}
  18. {$inline on}
  19. {$calling mwpascal}
  20. unit TextCommon;
  21. interface
  22. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  23. {$setc GAP_INTERFACES_VERSION := $0308}
  24. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  25. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  26. {$endc}
  27. {$ifc defined CPUPOWERPC and defined CPUI386}
  28. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  29. {$endc}
  30. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  31. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  32. {$endc}
  33. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  34. {$setc __ppc__ := 1}
  35. {$elsec}
  36. {$setc __ppc__ := 0}
  37. {$endc}
  38. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  39. {$setc __ppc64__ := 1}
  40. {$elsec}
  41. {$setc __ppc64__ := 0}
  42. {$endc}
  43. {$ifc not defined __i386__ and defined CPUI386}
  44. {$setc __i386__ := 1}
  45. {$elsec}
  46. {$setc __i386__ := 0}
  47. {$endc}
  48. {$ifc not defined __x86_64__ and defined CPUX86_64}
  49. {$setc __x86_64__ := 1}
  50. {$elsec}
  51. {$setc __x86_64__ := 0}
  52. {$endc}
  53. {$ifc not defined __arm__ and defined CPUARM}
  54. {$setc __arm__ := 1}
  55. {$elsec}
  56. {$setc __arm__ := 0}
  57. {$endc}
  58. {$ifc not defined __arm64__ and defined CPUAARCH64}
  59. {$setc __arm64__ := 1}
  60. {$elsec}
  61. {$setc __arm64__ := 0}
  62. {$endc}
  63. {$ifc defined cpu64}
  64. {$setc __LP64__ := 1}
  65. {$elsec}
  66. {$setc __LP64__ := 0}
  67. {$endc}
  68. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  69. {$error Conflicting definitions for __ppc__ and __i386__}
  70. {$endc}
  71. {$ifc defined __ppc__ and __ppc__}
  72. {$setc TARGET_CPU_PPC := TRUE}
  73. {$setc TARGET_CPU_PPC64 := FALSE}
  74. {$setc TARGET_CPU_X86 := FALSE}
  75. {$setc TARGET_CPU_X86_64 := FALSE}
  76. {$setc TARGET_CPU_ARM := FALSE}
  77. {$setc TARGET_CPU_ARM64 := FALSE}
  78. {$setc TARGET_OS_MAC := TRUE}
  79. {$setc TARGET_OS_IPHONE := FALSE}
  80. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  81. {$setc TARGET_OS_EMBEDDED := FALSE}
  82. {$elifc defined __ppc64__ and __ppc64__}
  83. {$setc TARGET_CPU_PPC := FALSE}
  84. {$setc TARGET_CPU_PPC64 := TRUE}
  85. {$setc TARGET_CPU_X86 := FALSE}
  86. {$setc TARGET_CPU_X86_64 := FALSE}
  87. {$setc TARGET_CPU_ARM := FALSE}
  88. {$setc TARGET_CPU_ARM64 := FALSE}
  89. {$setc TARGET_OS_MAC := TRUE}
  90. {$setc TARGET_OS_IPHONE := FALSE}
  91. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  92. {$setc TARGET_OS_EMBEDDED := FALSE}
  93. {$elifc defined __i386__ and __i386__}
  94. {$setc TARGET_CPU_PPC := FALSE}
  95. {$setc TARGET_CPU_PPC64 := FALSE}
  96. {$setc TARGET_CPU_X86 := TRUE}
  97. {$setc TARGET_CPU_X86_64 := FALSE}
  98. {$setc TARGET_CPU_ARM := FALSE}
  99. {$setc TARGET_CPU_ARM64 := FALSE}
  100. {$ifc defined(iphonesim)}
  101. {$setc TARGET_OS_MAC := FALSE}
  102. {$setc TARGET_OS_IPHONE := TRUE}
  103. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  104. {$elsec}
  105. {$setc TARGET_OS_MAC := TRUE}
  106. {$setc TARGET_OS_IPHONE := FALSE}
  107. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  108. {$endc}
  109. {$setc TARGET_OS_EMBEDDED := FALSE}
  110. {$elifc defined __x86_64__ and __x86_64__}
  111. {$setc TARGET_CPU_PPC := FALSE}
  112. {$setc TARGET_CPU_PPC64 := FALSE}
  113. {$setc TARGET_CPU_X86 := FALSE}
  114. {$setc TARGET_CPU_X86_64 := TRUE}
  115. {$setc TARGET_CPU_ARM := FALSE}
  116. {$setc TARGET_CPU_ARM64 := FALSE}
  117. {$ifc defined(iphonesim)}
  118. {$setc TARGET_OS_MAC := FALSE}
  119. {$setc TARGET_OS_IPHONE := TRUE}
  120. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  121. {$elsec}
  122. {$setc TARGET_OS_MAC := TRUE}
  123. {$setc TARGET_OS_IPHONE := FALSE}
  124. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  125. {$endc}
  126. {$setc TARGET_OS_EMBEDDED := FALSE}
  127. {$elifc defined __arm__ and __arm__}
  128. {$setc TARGET_CPU_PPC := FALSE}
  129. {$setc TARGET_CPU_PPC64 := FALSE}
  130. {$setc TARGET_CPU_X86 := FALSE}
  131. {$setc TARGET_CPU_X86_64 := FALSE}
  132. {$setc TARGET_CPU_ARM := TRUE}
  133. {$setc TARGET_CPU_ARM64 := FALSE}
  134. { will require compiler define when/if other Apple devices with ARM cpus ship }
  135. {$setc TARGET_OS_MAC := FALSE}
  136. {$setc TARGET_OS_IPHONE := TRUE}
  137. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  138. {$setc TARGET_OS_EMBEDDED := TRUE}
  139. {$elifc defined __arm64__ and __arm64__}
  140. {$setc TARGET_CPU_PPC := FALSE}
  141. {$setc TARGET_CPU_PPC64 := FALSE}
  142. {$setc TARGET_CPU_X86 := FALSE}
  143. {$setc TARGET_CPU_X86_64 := FALSE}
  144. {$setc TARGET_CPU_ARM := FALSE}
  145. {$setc TARGET_CPU_ARM64 := TRUE}
  146. { will require compiler define when/if other Apple devices with ARM cpus ship }
  147. {$setc TARGET_OS_MAC := FALSE}
  148. {$setc TARGET_OS_IPHONE := TRUE}
  149. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  150. {$setc TARGET_OS_EMBEDDED := TRUE}
  151. {$elsec}
  152. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  153. {$endc}
  154. {$ifc defined __LP64__ and __LP64__ }
  155. {$setc TARGET_CPU_64 := TRUE}
  156. {$elsec}
  157. {$setc TARGET_CPU_64 := FALSE}
  158. {$endc}
  159. {$ifc defined FPC_BIG_ENDIAN}
  160. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  161. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  162. {$elifc defined FPC_LITTLE_ENDIAN}
  163. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  164. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  165. {$elsec}
  166. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  167. {$endc}
  168. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  169. {$setc CALL_NOT_IN_CARBON := FALSE}
  170. {$setc OLDROUTINENAMES := FALSE}
  171. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  172. {$setc OPAQUE_UPP_TYPES := TRUE}
  173. {$setc OTCARBONAPPLICATION := TRUE}
  174. {$setc OTKERNEL := FALSE}
  175. {$setc PM_USE_SESSION_APIS := TRUE}
  176. {$setc TARGET_API_MAC_CARBON := TRUE}
  177. {$setc TARGET_API_MAC_OS8 := FALSE}
  178. {$setc TARGET_API_MAC_OSX := TRUE}
  179. {$setc TARGET_CARBON := TRUE}
  180. {$setc TARGET_CPU_68K := FALSE}
  181. {$setc TARGET_CPU_MIPS := FALSE}
  182. {$setc TARGET_CPU_SPARC := FALSE}
  183. {$setc TARGET_OS_UNIX := FALSE}
  184. {$setc TARGET_OS_WIN32 := FALSE}
  185. {$setc TARGET_RT_MAC_68881 := FALSE}
  186. {$setc TARGET_RT_MAC_CFM := FALSE}
  187. {$setc TARGET_RT_MAC_MACHO := TRUE}
  188. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  189. {$setc TYPE_BOOL := FALSE}
  190. {$setc TYPE_EXTENDED := FALSE}
  191. {$setc TYPE_LONGLONG := TRUE}
  192. uses MacTypes;
  193. {$endc} {not MACOSALLINCLUDE}
  194. {$ifc TARGET_OS_MAC}
  195. {$ALIGN MAC68K}
  196. {
  197. * Generic Text Alignment Constants
  198. *
  199. * Summary:
  200. * These constants are implemented to supplant the old TextEdit
  201. * Manager constants ( teFlushDefault, teCenter teFlushRight,
  202. * teFlushLeft ) These constants are used outside the context of the
  203. * legacy TextEdit Manager Framework. Use these as you would use the
  204. * old TextEdit.h constants to specify how text should be justified
  205. * (word aligned.) The new constants use the same values as the the
  206. * old TextEdit ones, for backwards compatibility.
  207. }
  208. const
  209. {
  210. * Flush according to the line direction
  211. }
  212. kTextFlushDefault = 0;
  213. {
  214. * Center justify (word alignment)
  215. }
  216. kTextCenter = 1;
  217. {
  218. * Flush right
  219. }
  220. kTextFlushRight = -1;
  221. {
  222. * Flush left
  223. }
  224. kTextFlushLeft = -2;
  225. { TextEncodingBase type & values }
  226. { (values 0-32 correspond to the Script Codes defined in Inside Macintosh: Text pages 6-52 and 6-53 }
  227. type
  228. TextEncodingBase = UInt32;
  229. const
  230. { Mac OS encodings}
  231. kTextEncodingMacRoman = 0;
  232. kTextEncodingMacJapanese = 1;
  233. kTextEncodingMacChineseTrad = 2;
  234. kTextEncodingMacKorean = 3;
  235. kTextEncodingMacArabic = 4;
  236. kTextEncodingMacHebrew = 5;
  237. kTextEncodingMacGreek = 6;
  238. kTextEncodingMacCyrillic = 7;
  239. kTextEncodingMacDevanagari = 9;
  240. kTextEncodingMacGurmukhi = 10;
  241. kTextEncodingMacGujarati = 11;
  242. kTextEncodingMacOriya = 12;
  243. kTextEncodingMacBengali = 13;
  244. kTextEncodingMacTamil = 14;
  245. kTextEncodingMacTelugu = 15;
  246. kTextEncodingMacKannada = 16;
  247. kTextEncodingMacMalayalam = 17;
  248. kTextEncodingMacSinhalese = 18;
  249. kTextEncodingMacBurmese = 19;
  250. kTextEncodingMacKhmer = 20;
  251. kTextEncodingMacThai = 21;
  252. kTextEncodingMacLaotian = 22;
  253. kTextEncodingMacGeorgian = 23;
  254. kTextEncodingMacArmenian = 24;
  255. kTextEncodingMacChineseSimp = 25;
  256. kTextEncodingMacTibetan = 26;
  257. kTextEncodingMacMongolian = 27;
  258. kTextEncodingMacEthiopic = 28;
  259. kTextEncodingMacCentralEurRoman = 29;
  260. kTextEncodingMacVietnamese = 30;
  261. kTextEncodingMacExtArabic = 31; { The following use script code 0, smRoman}
  262. kTextEncodingMacSymbol = 33;
  263. kTextEncodingMacDingbats = 34;
  264. kTextEncodingMacTurkish = 35;
  265. kTextEncodingMacCroatian = 36;
  266. kTextEncodingMacIcelandic = 37;
  267. kTextEncodingMacRomanian = 38;
  268. kTextEncodingMacCeltic = 39;
  269. kTextEncodingMacGaelic = 40;
  270. kTextEncodingMacKeyboardGlyphs = 41;
  271. { The following are older names for backward compatibility}
  272. const
  273. kTextEncodingMacTradChinese = kTextEncodingMacChineseTrad;
  274. kTextEncodingMacRSymbol = 8;
  275. kTextEncodingMacSimpChinese = kTextEncodingMacChineseSimp;
  276. kTextEncodingMacGeez = kTextEncodingMacEthiopic;
  277. kTextEncodingMacEastEurRoman = kTextEncodingMacCentralEurRoman;
  278. kTextEncodingMacUninterp = 32;
  279. {
  280. Beginning in Mac OS 8.5, the following meta-value is used to indicate Unicode in some parts
  281. of the Mac OS which previously only expected a Mac OS script code. In some of these places,
  282. only 7 bits are available to indicate encoding (script code), so kTextEncodingUnicodeDefault
  283. cannot be used. For example, kTextEncodingMacUnicode can be used to indicate Unicode in the
  284. 7-bit script code field of a Unicode input method's ComponentDescription.componentFlags field;
  285. it can also be used to indicate Unicode in the 16-bit script code field of an AppleEvent's
  286. typeIntlWritingCode text tag.
  287. }
  288. const
  289. kTextEncodingMacUnicode = $7E; { Meta-value, Unicode as a Mac encoding}
  290. { Variant Mac OS encodings that use script codes other than 0}
  291. const
  292. { The following use script code 4, smArabic}
  293. kTextEncodingMacFarsi = $8C; { Like MacArabic but uses Farsi digits}
  294. { The following use script code 7, smCyrillic}
  295. kTextEncodingMacUkrainian = $98; { Meta-value in TEC 1.5 & later; maps to kTextEncodingMacCyrillic variant }
  296. { The following use script code 28, smEthiopic}
  297. kTextEncodingMacInuit = $EC; { The following use script code 32, smUnimplemented}
  298. kTextEncodingMacVT100 = $FC; { VT100/102 font from Comm Toolbox: Latin-1 repertoire + box drawing etc}
  299. { Special Mac OS encodings}
  300. const
  301. kTextEncodingMacHFS = $FF; { Meta-value, should never appear in a table.}
  302. { Unicode & ISO UCS encodings begin at 0x100}
  303. const
  304. kTextEncodingUnicodeDefault = $0100; { Meta-value, should never appear in a table.}
  305. kTextEncodingUnicodeV1_1 = $0101;
  306. kTextEncodingISO10646_1993 = $0101; { Code points identical to Unicode 1.1}
  307. kTextEncodingUnicodeV2_0 = $0103; { New location for Korean Hangul}
  308. kTextEncodingUnicodeV2_1 = $0103; { We treat both Unicode 2.0 and Unicode 2.1 as 2.1}
  309. kTextEncodingUnicodeV3_0 = $0104;
  310. kTextEncodingUnicodeV3_1 = $0105; { Adds characters requiring surrogate pairs in UTF-16}
  311. kTextEncodingUnicodeV3_2 = $0106;
  312. kTextEncodingUnicodeV4_0 = $0108;
  313. kTextEncodingUnicodeV5_0 = $010A;
  314. kTextEncodingUnicodeV5_1 = $010B; { No constant for Unicode 5.2, but leave an opening.}
  315. kTextEncodingUnicodeV6_0 = $010D; { Adds many symbols, including emoji support.}
  316. kTextEncodingUnicodeV6_1 = $010E; { Adds emoji variation sequences, properties changes.}
  317. { ISO 8-bit and 7-bit encodings begin at 0x200}
  318. const
  319. kTextEncodingISOLatin1 = $0201; { ISO 8859-1, Western European}
  320. kTextEncodingISOLatin2 = $0202; { ISO 8859-2, Central European}
  321. kTextEncodingISOLatin3 = $0203; { ISO 8859-3, South European (Maltese...)}
  322. kTextEncodingISOLatin4 = $0204; { ISO 8859-4, North European & some Baltic}
  323. kTextEncodingISOLatinCyrillic = $0205; { ISO 8859-5}
  324. kTextEncodingISOLatinArabic = $0206; { ISO 8859-6, = ASMO 708, =DOS CP 708}
  325. kTextEncodingISOLatinGreek = $0207; { ISO 8859-7}
  326. kTextEncodingISOLatinHebrew = $0208; { ISO 8859-8}
  327. kTextEncodingISOLatin5 = $0209; { ISO 8859-9, Turkish}
  328. kTextEncodingISOLatin6 = $020A; { ISO 8859-10, Nordic }
  329. kTextEncodingISOLatin7 = $020D; { ISO 8859-13, Baltic Rim }
  330. kTextEncodingISOLatin8 = $020E; { ISO 8859-14, Celtic }
  331. kTextEncodingISOLatin9 = $020F; { ISO 8859-15, 8859-1 changed for EURO & CP1252 letters }
  332. kTextEncodingISOLatin10 = $0210; { ISO 8859-16, Romanian}
  333. { MS-DOS & Windows encodings begin at 0x400}
  334. const
  335. kTextEncodingDOSLatinUS = $0400; { code page 437}
  336. kTextEncodingDOSGreek = $0405; { code page 737 (formerly code page 437G)}
  337. kTextEncodingDOSBalticRim = $0406; { code page 775}
  338. kTextEncodingDOSLatin1 = $0410; { code page 850, "Multilingual"}
  339. kTextEncodingDOSGreek1 = $0411; { code page 851}
  340. kTextEncodingDOSLatin2 = $0412; { code page 852, Slavic}
  341. kTextEncodingDOSCyrillic = $0413; { code page 855, IBM Cyrillic}
  342. kTextEncodingDOSTurkish = $0414; { code page 857, IBM Turkish}
  343. kTextEncodingDOSPortuguese = $0415; { code page 860}
  344. kTextEncodingDOSIcelandic = $0416; { code page 861}
  345. kTextEncodingDOSHebrew = $0417; { code page 862}
  346. kTextEncodingDOSCanadianFrench = $0418; { code page 863}
  347. kTextEncodingDOSArabic = $0419; { code page 864}
  348. kTextEncodingDOSNordic = $041A; { code page 865}
  349. kTextEncodingDOSRussian = $041B; { code page 866}
  350. kTextEncodingDOSGreek2 = $041C; { code page 869, IBM Modern Greek}
  351. kTextEncodingDOSThai = $041D; { code page 874, also for Windows}
  352. kTextEncodingDOSJapanese = $0420; { code page 932, also for Windows; Shift-JIS with additions}
  353. kTextEncodingDOSChineseSimplif = $0421; { code page 936, also for Windows; was EUC-CN, now GBK (EUC-CN extended)}
  354. kTextEncodingDOSKorean = $0422; { code page 949, also for Windows; Unified Hangul Code (EUC-KR extended)}
  355. kTextEncodingDOSChineseTrad = $0423; { code page 950, also for Windows; Big-5}
  356. kTextEncodingWindowsLatin1 = $0500; { code page 1252}
  357. kTextEncodingWindowsANSI = $0500; { code page 1252 (alternate name)}
  358. kTextEncodingWindowsLatin2 = $0501; { code page 1250, Central Europe}
  359. kTextEncodingWindowsCyrillic = $0502; { code page 1251, Slavic Cyrillic}
  360. kTextEncodingWindowsGreek = $0503; { code page 1253}
  361. kTextEncodingWindowsLatin5 = $0504; { code page 1254, Turkish}
  362. kTextEncodingWindowsHebrew = $0505; { code page 1255}
  363. kTextEncodingWindowsArabic = $0506; { code page 1256}
  364. kTextEncodingWindowsBalticRim = $0507; { code page 1257}
  365. kTextEncodingWindowsVietnamese = $0508; { code page 1258}
  366. kTextEncodingWindowsKoreanJohab = $0510; { code page 1361, for Windows NT}
  367. { Various national standards begin at 0x600}
  368. const
  369. kTextEncodingUS_ASCII = $0600;
  370. kTextEncodingANSEL = $0601; { ANSEL (ANSI Z39.47) for library use}
  371. kTextEncodingJIS_X0201_76 = $0620; { JIS Roman and 1-byte katakana (halfwidth)}
  372. kTextEncodingJIS_X0208_83 = $0621;
  373. kTextEncodingJIS_X0208_90 = $0622;
  374. kTextEncodingJIS_X0212_90 = $0623;
  375. kTextEncodingJIS_C6226_78 = $0624;
  376. kTextEncodingShiftJIS_X0213 = $0628; { Shift-JIS format encoding of JIS X0213 planes 1 and 2}
  377. kTextEncodingJIS_X0213_MenKuTen = $0629; { JIS X0213 in plane-row-column notation (3 bytes)}
  378. kTextEncodingGB_2312_80 = $0630;
  379. kTextEncodingGBK_95 = $0631; { annex to GB 13000-93; for Windows 95; EUC-CN extended}
  380. kTextEncodingGB_18030_2000 = $0632; { This is actually implemented as GB_18030_2005}
  381. kTextEncodingGB_18030_2005 = $0632;
  382. kTextEncodingKSC_5601_87 = $0640; { same as KSC 5601-92 without Johab annex}
  383. kTextEncodingKSC_5601_92_Johab = $0641; { KSC 5601-92 Johab annex}
  384. kTextEncodingCNS_11643_92_P1 = $0651; { CNS 11643-1992 plane 1}
  385. kTextEncodingCNS_11643_92_P2 = $0652; { CNS 11643-1992 plane 2}
  386. kTextEncodingCNS_11643_92_P3 = $0653; { CNS 11643-1992 plane 3 (was plane 14 in 1986 version)}
  387. { ISO 2022 collections begin at 0x800}
  388. const
  389. kTextEncodingISO_2022_JP = $0820; { RFC 1468}
  390. kTextEncodingISO_2022_JP_2 = $0821; { RFC 1554}
  391. kTextEncodingISO_2022_JP_1 = $0822; { RFC 2237}
  392. kTextEncodingISO_2022_JP_3 = $0823; { JIS X0213}
  393. kTextEncodingISO_2022_CN = $0830; { RFC 1922}
  394. kTextEncodingISO_2022_CN_EXT = $0831; { RFC 1922}
  395. kTextEncodingISO_2022_KR = $0840; { RFC 1557}
  396. { EUC collections begin at 0x900}
  397. const
  398. kTextEncodingEUC_JP = $0920; { ISO 646, 1-byte katakana, JIS 208, JIS 212}
  399. kTextEncodingEUC_CN = $0930; { ISO 646, GB 2312-80}
  400. kTextEncodingEUC_TW = $0931; { ISO 646, CNS 11643-1992 Planes 1-16}
  401. kTextEncodingEUC_KR = $0940; { RFC 1557: ISO 646, KS C 5601-1987}
  402. { Misc standards begin at 0xA00}
  403. const
  404. kTextEncodingShiftJIS = $0A01; { plain Shift-JIS}
  405. kTextEncodingKOI8_R = $0A02; { RFC 1489, Russian internet standard}
  406. kTextEncodingBig5 = $0A03; { Big-5 (has variants)}
  407. kTextEncodingMacRomanLatin1 = $0A04; { Mac OS Roman permuted to align with ISO Latin-1}
  408. kTextEncodingHZ_GB_2312 = $0A05; { HZ (RFC 1842, for Chinese mail & news)}
  409. kTextEncodingBig5_HKSCS_1999 = $0A06; { Big-5 with Hong Kong special char set supplement}
  410. kTextEncodingVISCII = $0A07; { RFC 1456, Vietnamese}
  411. kTextEncodingKOI8_U = $0A08; { RFC 2319, Ukrainian}
  412. kTextEncodingBig5_E = $0A09; { Taiwan Big-5E standard}
  413. { Other platform encodings}
  414. const
  415. kTextEncodingNextStepLatin = $0B01; { NextStep Latin encoding}
  416. kTextEncodingNextStepJapanese = $0B02; { NextStep Japanese encoding (variant of EUC-JP)}
  417. { EBCDIC & IBM host encodings begin at 0xC00}
  418. const
  419. kTextEncodingEBCDIC_LatinCore = $0C01; { Common base subset of EBCDIC Latin encodings}
  420. kTextEncodingEBCDIC_CP037 = $0C02; { code page 037, extended EBCDIC (Latin-1 set) for US,Canada...}
  421. { Special values}
  422. const
  423. kTextEncodingMultiRun = $0FFF; { Multi-encoding text with external run info}
  424. kTextEncodingUnknown = $FFFF; { Unknown or unspecified }
  425. { The following are older names for backward compatibility}
  426. const
  427. kTextEncodingEBCDIC_US = $0C01;
  428. { TextEncodingVariant type & values }
  429. type
  430. TextEncodingVariant = UInt32;
  431. { Default TextEncodingVariant, for any TextEncodingBase}
  432. const
  433. kTextEncodingDefaultVariant = 0;
  434. { Variants of kTextEncodingMacRoman }
  435. const
  436. kMacRomanDefaultVariant = 0; { meta value, maps to 1 or 2 depending on System }
  437. kMacRomanCurrencySignVariant = 1; { Mac OS version < 8.5, 0xDB is CURRENCY SIGN}
  438. kMacRomanEuroSignVariant = 2; { Mac OS version >= 8.5, 0xDB is EURO SIGN }
  439. { Variants of kTextEncodingMacCyrillic (for TEC 1.5 and later) }
  440. const
  441. kMacCyrillicDefaultVariant = 0; { meta value, maps to 1, 2, or 3 depending on System}
  442. kMacCyrillicCurrSignStdVariant = 1; { Mac OS < 9.0 (RU,BG), 0xFF = CURRENCY SIGN, 0xA2/0xB6 = CENT / PARTIAL DIFF.}
  443. kMacCyrillicCurrSignUkrVariant = 2; { Mac OS < 9.0 (UA,LangKit), 0xFF = CURRENCY SIGN, 0xA2/0xB6 = GHE WITH UPTURN}
  444. kMacCyrillicEuroSignVariant = 3; { Mac OS >= 9.0, 0xFF is EURO SIGN, 0xA2/0xB6 = GHE WITH UPTURN}
  445. { Variants of kTextEncodingMacIcelandic }
  446. const
  447. kMacIcelandicStdDefaultVariant = 0; { meta value, maps to 2 or 4 depending on System }
  448. kMacIcelandicTTDefaultVariant = 1; { meta value, maps to 3 or 5 depending on System }
  449. { The following are for Mac OS version < 8.5, 0xDB is CURRENCY SIGN }
  450. kMacIcelandicStdCurrSignVariant = 2; { 0xBB/0xBC are fem./masc. ordinal indicators}
  451. kMacIcelandicTTCurrSignVariant = 3; { 0xBB/0xBC are fi/fl ligatures}
  452. { The following are for Mac OS version >= 8.5, 0xDB is EURO SIGN }
  453. kMacIcelandicStdEuroSignVariant = 4; { 0xBB/0xBC are fem./masc. ordinal indicators}
  454. kMacIcelandicTTEuroSignVariant = 5; { 0xBB/0xBC are fi/fl ligatures}
  455. { Variants of kTextEncodingMacCroatian }
  456. const
  457. kMacCroatianDefaultVariant = 0; { meta value, maps to 1 or 2 depending on System }
  458. kMacCroatianCurrencySignVariant = 1; { Mac OS version < 8.5, 0xDB is CURRENCY SIGN }
  459. kMacCroatianEuroSignVariant = 2; { Mac OS version >= 8.5, 0xDB is EURO SIGN }
  460. { Variants of kTextEncodingMacRomanian }
  461. const
  462. kMacRomanianDefaultVariant = 0; { meta value, maps to 1 or 2 depending on System }
  463. kMacRomanianCurrencySignVariant = 1; { Mac OS version < 8.5, 0xDB is CURRENCY SIGN }
  464. kMacRomanianEuroSignVariant = 2; { Mac OS version >= 8.5, 0xDB is EURO SIGN }
  465. { Variants of kTextEncodingMacJapanese}
  466. const
  467. kMacJapaneseStandardVariant = 0;
  468. kMacJapaneseStdNoVerticalsVariant = 1;
  469. kMacJapaneseBasicVariant = 2;
  470. kMacJapanesePostScriptScrnVariant = 3;
  471. kMacJapanesePostScriptPrintVariant = 4;
  472. kMacJapaneseVertAtKuPlusTenVariant = 5;
  473. { Variants of kTextEncodingMacArabic}
  474. const
  475. kMacArabicStandardVariant = 0; { 0xC0 is 8-spoke asterisk, 0x2A & 0xAA are asterisk (e.g. Cairo)}
  476. kMacArabicTrueTypeVariant = 1; { 0xC0 is asterisk, 0x2A & 0xAA are multiply signs (e.g. Baghdad)}
  477. kMacArabicThuluthVariant = 2; { 0xC0 is Arabic five-point star, 0x2A & 0xAA are multiply signs}
  478. kMacArabicAlBayanVariant = 3; { 8-spoke asterisk, multiply sign, Koranic ligatures & parens}
  479. { Variants of kTextEncodingMacFarsi}
  480. const
  481. kMacFarsiStandardVariant = 0; { 0xC0 is 8-spoke asterisk, 0x2A & 0xAA are asterisk (e.g. Tehran)}
  482. kMacFarsiTrueTypeVariant = 1; { asterisk, multiply signs, Koranic ligatures, geometric shapes}
  483. { Variants of kTextEncodingMacHebrew}
  484. const
  485. kMacHebrewStandardVariant = 0;
  486. kMacHebrewFigureSpaceVariant = 1;
  487. { Variants of kTextEncodingMacGreek}
  488. const
  489. kMacGreekDefaultVariant = 0; { meta value, maps to 1 or 2 depending on System}
  490. kMacGreekNoEuroSignVariant = 1; { Mac OS version < 9.2.2, 0x9C is SOFT HYPHEN, 0xFF is undefined}
  491. kMacGreekEuroSignVariant = 2; { Mac OS version >= 9.2.2, 0x9C is EURO SIGN, 0xFF is SOFT HYPHEN}
  492. { Variants of kTextEncodingMacVT100 }
  493. const
  494. kMacVT100DefaultVariant = 0; { meta value, maps to 1 or 2 depending on System }
  495. kMacVT100CurrencySignVariant = 1; { Mac OS version < 8.5, 0xDB is CURRENCY SIGN }
  496. kMacVT100EuroSignVariant = 2; { Mac OS version >= 8.5, 0xDB is EURO SIGN }
  497. { Variants of Unicode & ISO 10646 encodings}
  498. const
  499. kUnicodeNoSubset = 0;
  500. kUnicodeNormalizationFormD = 5; { canonical decomposition (NFD); excludes composed chars}
  501. kUnicodeNormalizationFormC = 3; { canonical composition (NFC); uses the composed chars as of Unicode 3.1}
  502. kUnicodeHFSPlusDecompVariant = 8; { decomposition for HFS+; doesn't decompose in 2000-2FFF, F900-FAFF, 2F800-2FAFF}
  503. kUnicodeHFSPlusCompVariant = 9; { composition based on HFS+ decomposition}
  504. { Variants of kTextEncodingISOLatin1}
  505. const
  506. kISOLatin1StandardVariant = 0;
  507. kISOLatin1MusicCDVariant = 1;
  508. {
  509. Variants of kTextEncodingISOLatinArabic, kTextEncodingISOLatinHebrew.
  510. Per RFC 1556 and ECMA TR/53, there are three ways of handling bidirectional text
  511. in the ISO character sets 8859-6 (Arabic) and 8859-8 (Hebrew).
  512. 1. Implicit or Logical order is "a presentation method in which the direction is
  513. determined by an algorithm according to the type of characters and their position
  514. relative to the adjacent characters and according to their primary direction." This
  515. is the method normally used for Unicode and for the Mac OS and Windows Arabic and
  516. Hebrew encodings.
  517. 2. Visual order assumes the text is already ordered such that it can be displayed
  518. in a left-to-right display direction with no further directional processing. This
  519. is equivalent to treating all characters as having strong left-right directionality.
  520. This is the default assumed for internet Hebrew text encoded in ISO 8859-8, unless
  521. the charset label suffix specifically indicates implicit (-i) or explicit (-e)
  522. ordering.
  523. 3. Explicit order is "a presentation method in which the direction is explicitly
  524. defined by using control sequences which are interleaved within the text and are
  525. used for direction determination."
  526. }
  527. const
  528. kISOLatinArabicImplicitOrderVariant = 0;
  529. kISOLatinArabicVisualOrderVariant = 1;
  530. kISOLatinArabicExplicitOrderVariant = 2;
  531. const
  532. kISOLatinHebrewImplicitOrderVariant = 0;
  533. kISOLatinHebrewVisualOrderVariant = 1;
  534. kISOLatinHebrewExplicitOrderVariant = 2;
  535. { Variants of kTextEncodingWindowsLatin1}
  536. const
  537. kWindowsLatin1StandardVariant = 0;
  538. kWindowsLatin1PalmVariant = 1; { PalmSource variant of cp1252}
  539. { Variants of kTextEncodingDOSJapanese}
  540. const
  541. kDOSJapaneseStandardVariant = 0;
  542. kDOSJapanesePalmVariant = 1; { PalmSource variant of cp932}
  543. {
  544. Variants of EUC_CN
  545. The DOSVariant is like kTextEncodingDOSChineseSimplif, but with the
  546. basic EUC_CN part mapped as per kTextEncodingEUC_CN.
  547. }
  548. const
  549. kEUC_CN_BasicVariant = 0;
  550. kEUC_CN_DOSVariant = 1;
  551. {
  552. Variants of EUC_KR
  553. The DOSVariant is like kTextEncodingDOSKorean, but with the
  554. basic EUC_KR part mapped as per kTextEncodingEUC_KR.
  555. }
  556. const
  557. kEUC_KR_BasicVariant = 0;
  558. kEUC_KR_DOSVariant = 1;
  559. {
  560. Variants of ShiftJIS
  561. The DOSVariant is like kTextEncodingDOSJapanese, but with the
  562. basic ShiftJIS part mapped as per kTextEncodingShiftJIS.
  563. }
  564. const
  565. kShiftJIS_BasicVariant = 0;
  566. kShiftJIS_DOSVariant = 1;
  567. kShiftJIS_MusicCDVariant = 2; { MusicShiftJIS, per RIS-506 (RIAJ)}
  568. {
  569. Variants of Big-5 encoding
  570. The DOSVariant is like kTextEncodingDOSChineseTrad, but with the
  571. basic Big5 part mapped as per kTextEncodingBig5.
  572. }
  573. const
  574. kBig5_BasicVariant = 0;
  575. kBig5_StandardVariant = 1; { 0xC6A1-0xC7FC: kana, Cyrillic, enclosed numerics}
  576. kBig5_ETenVariant = 2; { adds kana, Cyrillic, radicals, etc with hi bytes C6-C8,F9}
  577. kBig5_DOSVariant = 3;
  578. { Variants of MacRomanLatin1 }
  579. const
  580. kMacRomanLatin1DefaultVariant = 0; { meta value, maps to others depending on System}
  581. kMacRomanLatin1StandardVariant = 2; { permuted MacRoman, EuroSignVariant}
  582. kMacRomanLatin1TurkishVariant = 6; { permuted MacTurkish}
  583. kMacRomanLatin1CroatianVariant = 8; { permuted MacCroatian, EuroSignVariant}
  584. kMacRomanLatin1IcelandicVariant = 11; { permuted MacIcelandic, StdEuroSignVariant}
  585. kMacRomanLatin1RomanianVariant = 14; { permuted MacRomanian, EuroSignVariant}
  586. { Unicode variants not yet supported (and not fully defined)}
  587. const
  588. kUnicodeNoCompatibilityVariant = 1;
  589. kUnicodeNoCorporateVariant = 4;
  590. { The following are older names for backward compatibility}
  591. const
  592. kMacRomanStandardVariant = 0;
  593. kMacIcelandicStandardVariant = 0;
  594. kMacIcelandicTrueTypeVariant = 1;
  595. kJapaneseStandardVariant = 0;
  596. kJapaneseStdNoVerticalsVariant = 1;
  597. kJapaneseBasicVariant = 2;
  598. kJapanesePostScriptScrnVariant = 3;
  599. kJapanesePostScriptPrintVariant = 4;
  600. kJapaneseVertAtKuPlusTenVariant = 5;
  601. kTextEncodingShiftJIS_X0213_00 = $0628; { Shift-JIS format encoding of JIS X0213 planes 1 and 2}
  602. { kJapaneseStdNoOneByteKanaVariant = 6, // replaced by kJapaneseNoOneByteKanaOption}
  603. { kJapaneseBasicNoOneByteKanaVariant = 7, // replaced by kJapaneseNoOneByteKanaOption }
  604. kHebrewStandardVariant = 0;
  605. kHebrewFigureSpaceVariant = 1; { Old Unicode variants. Variant 2 (kUnicodeCanonicalDecompVariant, kUnicodeMaxDecomposedVariant) is ambiguous and means}
  606. { different things in different contexts. When normalizing (using ConvertFromUnicodeToText to convert from arbitrary}
  607. { Unicode to a normalized form), Unicode variant 2 means the same thing as kUnicodeNormalizationFormD (i.e. NFD).}
  608. { However, when converting between Unicode and traditional Mac OS encodings, Unicode variant 2 means the same thing as}
  609. { kUnicodeHFSPlusDecompVariant (i.e. the special HFS decomposition which excludes some character ranges from normalization).}
  610. { For clarity, please use the less ambiguous constants: kUnicodeNormalizationFormD = 5, kUnicodeHFSPlusDecompVariant = 8.}
  611. { }
  612. kUnicodeCanonicalDecompVariant = 2; { use kUnicodeNormalizationFormD or kUnicodeHFSPlusDecompVariant}
  613. kUnicodeMaxDecomposedVariant = 2; { use kUnicodeNormalizationFormD or kUnicodeHFSPlusDecompVariant}
  614. kUnicodeCanonicalCompVariant = 3; { replaced by kUnicodeNormalizationFormC}
  615. kUnicodeNoComposedVariant = 3; { this really meant NoComposing; replaced by kUnicodeNormalizationFormC}
  616. { TextEncodingFormat type & values }
  617. type
  618. TextEncodingFormat = UInt32;
  619. const
  620. { Default TextEncodingFormat for any TextEncodingBase}
  621. kTextEncodingDefaultFormat = 0; { Formats for Unicode & ISO 10646}
  622. kUnicodeUTF16Format = 0; { UTF16 form (16-bit units), native or external byte order (see below)}
  623. kUnicodeUTF7Format = 1; { UTF7 form}
  624. kUnicodeUTF8Format = 2; { UTF8 form}
  625. kUnicodeUTF32Format = 3; { UTF32 form (32-bit units), native or external byte order (see below)}
  626. kUnicodeUTF16BEFormat = 4; { UTF16 form, explicit big-endian byte order, no BOM}
  627. kUnicodeUTF16LEFormat = 5; { UTF16 form, explicit little-endian byte order, no BOM}
  628. kUnicodeUTF32BEFormat = 6; { UTF32 form, explicit big-endian byte order, no BOM}
  629. kUnicodeUTF32LEFormat = 7; { UTF32 form, explicit little-endian byte order, no BOM}
  630. kUnicodeSCSUFormat = 8; { Std. Compression Scheme for Unicode, Unicode Tech Std. #6}
  631. { Note for kUnicodeUTF16Format and kUnicodeUTF32Format:}
  632. { - An array of UTF16Char (UniChar) or UTF32Char is normally understood to use "internal" or}
  633. { platform-native byte ordering for kUnicodeUTF16Format and kUnicodeUTF32Format; the array MAY}
  634. { begin with byte-order mark (BOM), but the BOM should match the internal ordering.}
  635. { - If an array of bytes (such as char *) that can be in various encodings is specified to be}
  636. { in Unicode with kUnicodeUTF16Format or kUnicodeUTF32Format (not explicitly BE or LE), then it}
  637. { is assumed to use "external" byte ordering, which means: If there is a BOM at the beginning}
  638. { of text, the BOM specifies the byte ordering, otherwise big-endian is assumed.}
  639. { Synonyms for some Unicode formats}
  640. kUnicode16BitFormat = 0;
  641. kUnicode32BitFormat = 3;
  642. { TextEncoding type }
  643. type
  644. TextEncoding = UInt32;
  645. TextEncoding_fix = TextEncoding; { used as field type when a record declaration contains a TextEncoding field identifier }
  646. TextEncodingPtr = ^TextEncoding; { when a VAR xx: TextEncoding parameter can be nil, it is changed to xx: TextEncodingPtr }
  647. { name part selector for GetTextEncodingName}
  648. type
  649. TextEncodingNameSelector = UInt32;
  650. const
  651. kTextEncodingFullName = 0;
  652. kTextEncodingBaseName = 1;
  653. kTextEncodingVariantName = 2;
  654. kTextEncodingFormatName = 3;
  655. { Types used in conversion }
  656. type
  657. TextEncodingRun = record
  658. offset: ByteOffset;
  659. textEncoding: TextEncoding_fix;
  660. end;
  661. TextEncodingRunPtr = ^TextEncodingRun;
  662. type
  663. ConstTextEncodingRunPtr = {const} TextEncodingRunPtr;
  664. ScriptCodeRun = record
  665. offset: ByteOffset;
  666. script: ScriptCode;
  667. end;
  668. ScriptCodeRunPtr = ^ScriptCodeRun;
  669. type
  670. ConstScriptCodeRunPtr = {const} ScriptCodeRunPtr;
  671. TextPtr = UInt8Ptr;
  672. ConstTextPtr = {const} UInt8Ptr;
  673. { Basic types for Unicode characters and strings:}
  674. type
  675. UniCharArrayPtr = UniCharPtr;
  676. ConstUniCharArrayPtr = {const} UniCharPtr;
  677. {
  678. UniCharArrayHandle is a handle type to correspond to UniCharArrayPtr,
  679. i.e. a handle to an array of UniChars (UInt16s).
  680. }
  681. type
  682. UniCharArrayHandle = ^UniCharArrayPtr;
  683. {
  684. UniCharArrayOffset is used to indicate an edge offset in an array
  685. of UniChars (UInt16s).
  686. }
  687. type
  688. UniCharArrayOffset = UNSIGNEDLONG;
  689. UniCharArrayOffsetPtr = ^UniCharArrayOffset;
  690. { enums for TextEncoding Conversion routines}
  691. const
  692. kTextScriptDontCare = -128;
  693. kTextLanguageDontCare = -128;
  694. kTextRegionDontCare = -128;
  695. { struct for TECGetInfo}
  696. type
  697. TECInfo = record
  698. format: UInt16; { format code for this struct}
  699. tecVersion: UInt16; { TEC version in BCD, e.g. 0x0121 for 1.2.1}
  700. tecTextConverterFeatures: UInt32; { bitmask indicating TEC features/fixes}
  701. tecUnicodeConverterFeatures: UInt32; { bitmask indicating UnicodeConverter features/fixes}
  702. tecTextCommonFeatures: UInt32; { bitmask indicating TextCommon features/fixes}
  703. tecTextEncodingsFolderName: Str31; { localized name of Text Encodings folder (pascal string)}
  704. tecExtensionFileName: Str31; { localized name of TEC extension (pascal string)}
  705. tecLowestTEFileVersion: UInt16; { Lowest version (BCD) of all files in Text Encodings folder}
  706. tecHighestTEFileVersion: UInt16; { Highest version (BCD) of all files in Text Encodings folder}
  707. end;
  708. TECInfoPtr = ^TECInfo;
  709. type
  710. TECInfoHandle = ^TECInfoPtr;
  711. { Value for TECInfo format code}
  712. const
  713. kTECInfoCurrentFormat = 2; { any future formats will just add fields at the end}
  714. {
  715. Defined feature/fix bits for tecUnicodeConverterFeatures field
  716. Bit: Meaning if set:
  717. ---- ---------------
  718. kTECKeepInfoFixBit Unicode Converter no longer ignores other control flags if
  719. kUnicodeKeepInfoBit is set. Bug fix in TEC Manager 1.2.1.
  720. kTECFallbackTextLengthFixBit Unicode Converter honors the *srcConvLen and *destConvLen
  721. returned by caller-supplied fallback handler for any status it
  722. returns except for kTECUnmappableElementErr (previously it only
  723. honored these values if noErr was returned). Bug fix in TEC
  724. Manager 1.2.1.
  725. kTECTextRunBitClearFixBit ConvertFromUnicodeToTextRun & ConvertFromUnicodeToScriptCodeRun
  726. function correctly if the kUnicodeTextRunBit is set (previously
  727. their determination of best target encoding was incorrect). Bug
  728. fix in TEC Manager 1.3.
  729. kTECTextToUnicodeScanFixBit ConvertFromTextToUnicode uses an improved scanner and maintains
  730. some resulting state information, which it uses for mapping.
  731. This has several effects:
  732. - Improved mapping of 0x30-0x39 digits in Mac OS Arabic, fewer
  733. direction overrides when mapping Mac OS Arabic & Hebrew, and
  734. improved mapping of certain characters in Indic encodings.
  735. - Malformed input produces kTextMalformedInputErr.
  736. - ConvertFromTextToUnicode accepts and uses the control flags
  737. kUnicodeKeepInfoMask and kUnicodeStringUnterminatedMask.
  738. Bug fix and enhancement in TEC Manager 1.3.
  739. kTECAddForceASCIIChangesBit Define new control flag bits kUnicodeForceASCIIRangeBit and
  740. kUnicodeNoHalfwidthCharsBit for use with
  741. ConvertFromTextToUnicode, ConvertFromUnicodeToText, etc.
  742. Enhancement in TEC Manager 1.4.
  743. kTECPreferredEncodingFixBit CreateUnicodeToTextRunInfo and related functions fix a problem
  744. that occurred when a preferred encoding was specified that did
  745. not match the System script; the preferred script was not
  746. actually placed first in the ordered list of encodings to use.
  747. Bug fix in TEC Manager 1.4.
  748. kTECAddTextRunHeuristicsBit Define new control flag bit kUnicodeTextRunHeuristicsBit for
  749. use with ConvertFromUnicodeToTextRun.
  750. kTECAddFallbackInterruptBit Define new option kUnicodeFallbackInterruptSafeMask for use
  751. with SetFallbackUnicodeToText. If a client fallback handler is
  752. installed without specifying this bit, ConvertFromUnicodeToText
  753. will HLock the tables it uses (in case the fallback handler
  754. moves memory); otherwise, it won't.
  755. }
  756. const
  757. kTECKeepInfoFixBit = 0;
  758. kTECFallbackTextLengthFixBit = 1;
  759. kTECTextRunBitClearFixBit = 2;
  760. kTECTextToUnicodeScanFixBit = 3;
  761. kTECAddForceASCIIChangesBit = 4;
  762. kTECPreferredEncodingFixBit = 5;
  763. kTECAddTextRunHeuristicsBit = 6;
  764. kTECAddFallbackInterruptBit = 7;
  765. const
  766. kTECKeepInfoFixMask = 1 shl kTECKeepInfoFixBit;
  767. kTECFallbackTextLengthFixMask = 1 shl kTECFallbackTextLengthFixBit;
  768. kTECTextRunBitClearFixMask = 1 shl kTECTextRunBitClearFixBit;
  769. kTECTextToUnicodeScanFixMask = 1 shl kTECTextToUnicodeScanFixBit;
  770. kTECAddForceASCIIChangesMask = 1 shl kTECAddForceASCIIChangesBit;
  771. kTECPreferredEncodingFixMask = 1 shl kTECPreferredEncodingFixBit;
  772. kTECAddTextRunHeuristicsMask = 1 shl kTECAddTextRunHeuristicsBit;
  773. kTECAddFallbackInterruptMask = 1 shl kTECAddFallbackInterruptBit;
  774. {
  775. -------------------------------------------------------------------------------------------------
  776. CONSTANTS for common and special Unicode code values
  777. -------------------------------------------------------------------------------------------------
  778. }
  779. const
  780. kUnicodeByteOrderMark = $FEFF;
  781. kUnicodeObjectReplacement = $FFFC; { placeholder for non-text object}
  782. kUnicodeReplacementChar = $FFFD; { Unicode replacement for unconvertable input char}
  783. kUnicodeSwappedByteOrderMark = $FFFE; { not a Unicode char; byte-swapped version of FEFF}
  784. kUnicodeNotAChar = $FFFF; { not a Unicode char; may be used as a terminator}
  785. {
  786. -------------------------------------------------------------------------------------------------
  787. CONSTANTS & DATA STRUCTURES for Unicode Properties
  788. -------------------------------------------------------------------------------------------------
  789. }
  790. type
  791. UCCharPropertyType = SInt32;
  792. const
  793. kUCCharPropTypeGenlCategory = 1; { requests enumeration value}
  794. kUCCharPropTypeCombiningClass = 2; { requests numeric value 0..255}
  795. kUCCharPropTypeBidiCategory = 3; { requests enumeration value}
  796. kUCCharPropTypeDecimalDigitValue = 4; { requests numeric value 0..9 for decimal digit chars (get err for others)}
  797. type
  798. UCCharPropertyValue = UInt32;
  799. { General Category enumeration values (requested by kUCCharPropTypeGenlCategory)}
  800. const
  801. { Normative categories:}
  802. kUCGenlCatOtherNotAssigned = 0; { Cn Other, Not Assigned}
  803. kUCGenlCatOtherControl = 1; { Cc Other, Control}
  804. kUCGenlCatOtherFormat = 2; { Cf Other, Format}
  805. kUCGenlCatOtherSurrogate = 3; { Cs Other, Surrogate}
  806. kUCGenlCatOtherPrivateUse = 4; { Co Other, Private Use}
  807. kUCGenlCatMarkNonSpacing = 5; { Mn Mark, Non-Spacing}
  808. kUCGenlCatMarkSpacingCombining = 6; { Mc Mark, Spacing Combining}
  809. kUCGenlCatMarkEnclosing = 7; { Me Mark, Enclosing}
  810. kUCGenlCatNumberDecimalDigit = 8; { Nd Number, Decimal Digit}
  811. kUCGenlCatNumberLetter = 9; { Nl Number, Letter}
  812. kUCGenlCatNumberOther = 10; { No Number, Other}
  813. kUCGenlCatSeparatorSpace = 11; { Zs Separator, Space}
  814. kUCGenlCatSeparatorLine = 12; { Zl Separator, Line}
  815. kUCGenlCatSeparatorParagraph = 13; { Zp Separator, Paragraph}
  816. kUCGenlCatLetterUppercase = 14; { Lu Letter, Uppercase}
  817. kUCGenlCatLetterLowercase = 15; { Ll Letter, Lowercase}
  818. kUCGenlCatLetterTitlecase = 16; { Lt Letter, Titlecase}
  819. { Informative categories:}
  820. kUCGenlCatLetterModifier = 17; { Lm Letter, Modifier}
  821. kUCGenlCatLetterOther = 18; { Lo Letter, Other}
  822. kUCGenlCatPunctConnector = 20; { Pc Punctuation, Connector}
  823. kUCGenlCatPunctDash = 21; { Pd Punctuation, Dash}
  824. kUCGenlCatPunctOpen = 22; { Ps Punctuation, Open}
  825. kUCGenlCatPunctClose = 23; { Pe Punctuation, Close}
  826. kUCGenlCatPunctInitialQuote = 24; { Pi Punctuation, Initial quote}
  827. kUCGenlCatPunctFinalQuote = 25; { Pf Punctuation, Final quote}
  828. kUCGenlCatPunctOther = 26; { Po Punctuation, Other}
  829. kUCGenlCatSymbolMath = 28; { Sm Symbol, Math}
  830. kUCGenlCatSymbolCurrency = 29; { Sc Symbol, Currency}
  831. kUCGenlCatSymbolModifier = 30; { Sk Symbol, Modifier}
  832. kUCGenlCatSymbolOther = 31; { So Symbol, Other}
  833. { Bidirectional Category enumeration values (requested by kUCCharPropTypeBidiCategory)}
  834. const
  835. kUCBidiCatNotApplicable = 0; { for now use this for unassigned}
  836. { Strong types:}
  837. kUCBidiCatLeftRight = 1; { L Left-to-Right}
  838. kUCBidiCatRightLeft = 2; { R Right-to-Left}
  839. { Weak types:}
  840. kUCBidiCatEuroNumber = 3; { EN European Number}
  841. kUCBidiCatEuroNumberSeparator = 4; { ES European Number Separator}
  842. kUCBidiCatEuroNumberTerminator = 5; { ET European Number Terminator}
  843. kUCBidiCatArabicNumber = 6; { AN Arabic Number}
  844. kUCBidiCatCommonNumberSeparator = 7; { CS Common Number Separator}
  845. { Separators:}
  846. kUCBidiCatBlockSeparator = 8; { B Paragraph Separator (was Block Separator)}
  847. kUCBidiCatSegmentSeparator = 9; { S Segment Separator}
  848. { Neutrals:}
  849. kUCBidiCatWhitespace = 10; { WS Whitespace}
  850. kUCBidiCatOtherNeutral = 11; { ON Other Neutrals (unassigned codes could use this)}
  851. { New categories for Unicode 3.0}
  852. kUCBidiCatRightLeftArabic = 12; { AL Right-to-Left Arabic (was Arabic Letter)}
  853. kUCBidiCatLeftRightEmbedding = 13; { LRE Left-to-Right Embedding}
  854. kUCBidiCatRightLeftEmbedding = 14; { RLE Right-to-Left Embedding}
  855. kUCBidiCatLeftRightOverride = 15; { LRO Left-to-Right Override}
  856. kUCBidiCatRightLeftOverride = 16; { RLO Right-to-Left Override}
  857. kUCBidiCatPopDirectionalFormat = 17; { PDF Pop Directional Format}
  858. kUCBidiCatNonSpacingMark = 18; { NSM Non-Spacing Mark}
  859. kUCBidiCatBoundaryNeutral = 19; { BN Boundary Neutral}
  860. {
  861. -------------------------------------------------------------------------------------------------
  862. Prototypes for TextEncoding functions
  863. -------------------------------------------------------------------------------------------------
  864. }
  865. {
  866. * CreateTextEncoding()
  867. *
  868. * Availability:
  869. * Mac OS X: in version 10.0 and later in CoreServices.framework
  870. * CarbonLib: in CarbonLib 1.0 and later
  871. * Non-Carbon CFM: in TextCommon 1.1 and later
  872. }
  873. function CreateTextEncoding( encodingBase: TextEncodingBase; encodingVariant: TextEncodingVariant; encodingFormat: TextEncodingFormat ): TextEncoding; external name '_CreateTextEncoding';
  874. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  875. {
  876. * GetTextEncodingBase()
  877. *
  878. * Availability:
  879. * Mac OS X: in version 10.0 and later in CoreServices.framework
  880. * CarbonLib: in CarbonLib 1.0 and later
  881. * Non-Carbon CFM: in TextCommon 1.1 and later
  882. }
  883. function GetTextEncodingBase( encoding: TextEncoding ): TextEncodingBase; external name '_GetTextEncodingBase';
  884. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  885. {
  886. * GetTextEncodingVariant()
  887. *
  888. * Availability:
  889. * Mac OS X: in version 10.0 and later in CoreServices.framework
  890. * CarbonLib: in CarbonLib 1.0 and later
  891. * Non-Carbon CFM: in TextCommon 1.1 and later
  892. }
  893. function GetTextEncodingVariant( encoding: TextEncoding ): TextEncodingVariant; external name '_GetTextEncodingVariant';
  894. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  895. {
  896. * GetTextEncodingFormat()
  897. *
  898. * Availability:
  899. * Mac OS X: in version 10.0 and later in CoreServices.framework
  900. * CarbonLib: in CarbonLib 1.0 and later
  901. * Non-Carbon CFM: in TextCommon 1.1 and later
  902. }
  903. function GetTextEncodingFormat( encoding: TextEncoding ): TextEncodingFormat; external name '_GetTextEncodingFormat';
  904. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  905. {
  906. * ResolveDefaultTextEncoding()
  907. *
  908. * Availability:
  909. * Mac OS X: in version 10.0 and later in CoreServices.framework
  910. * CarbonLib: in CarbonLib 1.0 and later
  911. * Non-Carbon CFM: in TextCommon 1.1 and later
  912. }
  913. function ResolveDefaultTextEncoding( encoding: TextEncoding ): TextEncoding; external name '_ResolveDefaultTextEncoding';
  914. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  915. {
  916. * GetTextEncodingName()
  917. *
  918. * Availability:
  919. * Mac OS X: in version 10.0 and later in CoreServices.framework
  920. * CarbonLib: in CarbonLib 1.0 and later
  921. * Non-Carbon CFM: in TextCommon 1.1 and later
  922. }
  923. function GetTextEncodingName( iEncoding: TextEncoding; iNamePartSelector: TextEncodingNameSelector; iPreferredRegion: RegionCode; iPreferredEncoding: TextEncoding; iOutputBufLen: ByteCount; var oNameLength: ByteCount; oActualRegion: RegionCodePtr { can be NULL }; oActualEncoding: TextEncodingPtr { can be NULL }; oEncodingName: TextPtr ): OSStatus; external name '_GetTextEncodingName';
  924. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  925. {
  926. * TECGetInfo()
  927. *
  928. * Availability:
  929. * Mac OS X: in version 10.0 and later in CoreServices.framework
  930. * CarbonLib: in CarbonLib 1.0 and later
  931. * Non-Carbon CFM: in TextCommon 1.2.1 and later
  932. }
  933. function TECGetInfo( var tecInfo: TECInfoHandle ): OSStatus; external name '_TECGetInfo';
  934. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  935. {
  936. * UpgradeScriptInfoToTextEncoding()
  937. *
  938. * Availability:
  939. * Mac OS X: in version 10.0 and later in CoreServices.framework
  940. * CarbonLib: in CarbonLib 1.0 and later
  941. * Non-Carbon CFM: in TextCommon 1.1 and later
  942. }
  943. function UpgradeScriptInfoToTextEncoding( iTextScriptID: ScriptCode; iTextLanguageID: LangCode; iRegionID: RegionCode; iTextFontname: StringPtr; var oEncoding: TextEncoding ): OSStatus; external name '_UpgradeScriptInfoToTextEncoding';
  944. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  945. {
  946. * RevertTextEncodingToScriptInfo()
  947. *
  948. * Availability:
  949. * Mac OS X: in version 10.0 and later in CoreServices.framework
  950. * CarbonLib: in CarbonLib 1.0 and later
  951. * Non-Carbon CFM: in TextCommon 1.1 and later
  952. }
  953. function RevertTextEncodingToScriptInfo( iEncoding: TextEncoding; var oTextScriptID: ScriptCode; oTextLanguageID: LangCodePtr { can be NULL }; oTextFontname: StringPtr { can be NULL } ): OSStatus; external name '_RevertTextEncodingToScriptInfo';
  954. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  955. {
  956. * GetTextEncodingFromScriptInfo()
  957. *
  958. * Summary:
  959. * Converts any combination of a Mac OS script code, a language
  960. * code, and a region code to a text encoding.
  961. *
  962. * Discussion:
  963. * This function is almost identical to
  964. * UpgradeScriptInfoToTextEncoding except it doesn't take a font
  965. * name and it is available in CoreServices.
  966. *
  967. * Parameters:
  968. *
  969. * iTextScriptID:
  970. * A valid Script Manager script code. The Mac OS Script Manager
  971. * defines constants for script codes using this format: smXxx. To
  972. * designate the system script, specify the meta-value of
  973. * smSystemScript. To indicate that you do not want to provide a
  974. * script code for this parameter, specify the constant
  975. * kTextScriptDontCare.
  976. *
  977. * iTextLanguageID:
  978. * A valid Script Manager language code. The Mac OS Script Manager
  979. * defines constants for language codes using this format:
  980. * langXxx. To indicate that you do not want to provide a language
  981. * code for this parameter, specify the constant
  982. * kTextLanguageDontCare.
  983. *
  984. * iTextRegionID:
  985. * A valid Script Manager region code. The Mac OS Script Manager
  986. * defines constants for region codes using this format: verXxx.
  987. * To indicate that you do not want to provide a region code for
  988. * this parameter, specify the constant kTextRegionDontCare.
  989. *
  990. * oEncoding:
  991. * A pointer to a value of type TextEncoding. On return, this
  992. * value holds the text encoding specification that the function
  993. * created from the other values you provided.
  994. *
  995. * Availability:
  996. * Mac OS X: in version 10.2 and later in CoreServices.framework
  997. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  998. * Non-Carbon CFM: not available
  999. }
  1000. function GetTextEncodingFromScriptInfo( iTextScriptID: ScriptCode; iTextLanguageID: LangCode; iTextRegionID: RegionCode; var oEncoding: TextEncoding ): OSStatus; external name '_GetTextEncodingFromScriptInfo';
  1001. (* __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_NA) *)
  1002. {
  1003. * GetScriptInfoFromTextEncoding()
  1004. *
  1005. * Summary:
  1006. * Converts the given Mac OS text encoding specification to the
  1007. * corresponding script code and, if possible, language code.
  1008. *
  1009. * Discussion:
  1010. * This function is almost identical to
  1011. * RevertTextEncodingToScriptInfo except it doesn't return a font
  1012. * name and it is available in CoreServices.
  1013. *
  1014. * Parameters:
  1015. *
  1016. * iEncoding:
  1017. * The text encoding specification to be converted.
  1018. *
  1019. * oTextScriptID:
  1020. * A pointer to a value of type ScriptCode. On return, a Mac OS
  1021. * script code that corresponds to the text encoding specification
  1022. * you identified in the iEncoding parameter. If you do not pass a
  1023. * pointer for this parameter, the function returns a paramErr
  1024. * result code.
  1025. *
  1026. * oTextLanguageID:
  1027. * A pointer to a value of type LangCode. On input, if you do not
  1028. * want the function to return the language code, specify NULL as
  1029. * the value of this parameter. On return, the appropriate
  1030. * language code, if the language can be unambiguously derived
  1031. * from the text encoding specification, for example, Japanese,
  1032. * and you did not set the parameter to NULL. If you do not
  1033. * specify NULL on input and the language is ambiguousÑthat is,
  1034. * the function cannot accurately derive it from the text encoding
  1035. * specificationÑthe function returns a value of
  1036. * kTextLanguageDontCare.
  1037. *
  1038. * Availability:
  1039. * Mac OS X: in version 10.2 and later in CoreServices.framework
  1040. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  1041. * Non-Carbon CFM: not available
  1042. }
  1043. function GetScriptInfoFromTextEncoding( iEncoding: TextEncoding; var oTextScriptID: ScriptCode; oTextLanguageID: LangCodePtr { can be NULL } ): OSStatus; external name '_GetScriptInfoFromTextEncoding';
  1044. (* __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_NA) *)
  1045. {
  1046. * NearestMacTextEncodings()
  1047. *
  1048. * Availability:
  1049. * Mac OS X: in version 10.0 and later in CoreServices.framework
  1050. * CarbonLib: in CarbonLib 1.0 and later
  1051. * Non-Carbon CFM: in TextCommon 1.5 and later
  1052. }
  1053. function NearestMacTextEncodings( generalEncoding: TextEncoding; var bestMacEncoding: TextEncoding; var alternateMacEncoding: TextEncoding ): OSStatus; external name '_NearestMacTextEncodings';
  1054. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  1055. {
  1056. * UCGetCharProperty()
  1057. *
  1058. * Availability:
  1059. * Mac OS X: in version 10.0 and later in CoreServices.framework
  1060. * CarbonLib: in CarbonLib 1.0 and later
  1061. * Non-Carbon CFM: in TextCommon 1.5 and later
  1062. }
  1063. function UCGetCharProperty( charPtr: ConstUniCharPtr; textLength: UniCharCount; propType: UCCharPropertyType; var propValue: UCCharPropertyValue ): OSStatus; external name '_UCGetCharProperty';
  1064. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  1065. {
  1066. -------------------------------------------------------------------------------------------------
  1067. Surrogate pair utilities
  1068. -------------------------------------------------------------------------------------------------
  1069. }
  1070. // surrogate ranges
  1071. const
  1072. kUCHighSurrogateRangeStart = $D800;
  1073. kUCHighSurrogateRangeEnd = $DBFF;
  1074. kUCLowSurrogateRangeStart = $DC00;
  1075. kUCLowSurrogateRangeEnd = $DFFF;
  1076. {$endc} {TARGET_OS_MAC}
  1077. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  1078. end.
  1079. {$endc} {not MACOSALLINCLUDE}