UnicodeConverter.pas 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. {
  2. File: CarbonCore/UnicodeConverter.h
  3. Contains: Types, constants, and prototypes for Unicode Converter
  4. Copyright: © 1994-2011 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. {$modeswitch cblocks}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$calling mwpascal}
  21. unit UnicodeConverter;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  24. {$setc GAP_INTERFACES_VERSION := $0308}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  40. {$setc __ppc64__ := 1}
  41. {$elsec}
  42. {$setc __ppc64__ := 0}
  43. {$endc}
  44. {$ifc not defined __i386__ and defined CPUI386}
  45. {$setc __i386__ := 1}
  46. {$elsec}
  47. {$setc __i386__ := 0}
  48. {$endc}
  49. {$ifc not defined __x86_64__ and defined CPUX86_64}
  50. {$setc __x86_64__ := 1}
  51. {$elsec}
  52. {$setc __x86_64__ := 0}
  53. {$endc}
  54. {$ifc not defined __arm__ and defined CPUARM}
  55. {$setc __arm__ := 1}
  56. {$elsec}
  57. {$setc __arm__ := 0}
  58. {$endc}
  59. {$ifc not defined __arm64__ and defined CPUAARCH64}
  60. {$setc __arm64__ := 1}
  61. {$elsec}
  62. {$setc __arm64__ := 0}
  63. {$endc}
  64. {$ifc defined cpu64}
  65. {$setc __LP64__ := 1}
  66. {$elsec}
  67. {$setc __LP64__ := 0}
  68. {$endc}
  69. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  70. {$error Conflicting definitions for __ppc__ and __i386__}
  71. {$endc}
  72. {$ifc defined __ppc__ and __ppc__}
  73. {$setc TARGET_CPU_PPC := TRUE}
  74. {$setc TARGET_CPU_PPC64 := FALSE}
  75. {$setc TARGET_CPU_X86 := FALSE}
  76. {$setc TARGET_CPU_X86_64 := FALSE}
  77. {$setc TARGET_CPU_ARM := FALSE}
  78. {$setc TARGET_CPU_ARM64 := FALSE}
  79. {$setc TARGET_OS_MAC := TRUE}
  80. {$setc TARGET_OS_IPHONE := FALSE}
  81. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  82. {$setc TARGET_OS_EMBEDDED := FALSE}
  83. {$elifc defined __ppc64__ and __ppc64__}
  84. {$setc TARGET_CPU_PPC := FALSE}
  85. {$setc TARGET_CPU_PPC64 := TRUE}
  86. {$setc TARGET_CPU_X86 := FALSE}
  87. {$setc TARGET_CPU_X86_64 := FALSE}
  88. {$setc TARGET_CPU_ARM := FALSE}
  89. {$setc TARGET_CPU_ARM64 := FALSE}
  90. {$setc TARGET_OS_MAC := TRUE}
  91. {$setc TARGET_OS_IPHONE := FALSE}
  92. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  93. {$setc TARGET_OS_EMBEDDED := FALSE}
  94. {$elifc defined __i386__ and __i386__}
  95. {$setc TARGET_CPU_PPC := FALSE}
  96. {$setc TARGET_CPU_PPC64 := FALSE}
  97. {$setc TARGET_CPU_X86 := TRUE}
  98. {$setc TARGET_CPU_X86_64 := FALSE}
  99. {$setc TARGET_CPU_ARM := FALSE}
  100. {$setc TARGET_CPU_ARM64 := FALSE}
  101. {$ifc defined iphonesim}
  102. {$setc TARGET_OS_MAC := FALSE}
  103. {$setc TARGET_OS_IPHONE := TRUE}
  104. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  105. {$elsec}
  106. {$setc TARGET_OS_MAC := TRUE}
  107. {$setc TARGET_OS_IPHONE := FALSE}
  108. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  109. {$endc}
  110. {$setc TARGET_OS_EMBEDDED := FALSE}
  111. {$elifc defined __x86_64__ and __x86_64__}
  112. {$setc TARGET_CPU_PPC := FALSE}
  113. {$setc TARGET_CPU_PPC64 := FALSE}
  114. {$setc TARGET_CPU_X86 := FALSE}
  115. {$setc TARGET_CPU_X86_64 := TRUE}
  116. {$setc TARGET_CPU_ARM := FALSE}
  117. {$setc TARGET_CPU_ARM64 := FALSE}
  118. {$ifc defined iphonesim}
  119. {$setc TARGET_OS_MAC := FALSE}
  120. {$setc TARGET_OS_IPHONE := TRUE}
  121. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  122. {$elsec}
  123. {$setc TARGET_OS_MAC := TRUE}
  124. {$setc TARGET_OS_IPHONE := FALSE}
  125. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  126. {$endc}
  127. {$setc TARGET_OS_EMBEDDED := FALSE}
  128. {$elifc defined __arm__ and __arm__}
  129. {$setc TARGET_CPU_PPC := FALSE}
  130. {$setc TARGET_CPU_PPC64 := FALSE}
  131. {$setc TARGET_CPU_X86 := FALSE}
  132. {$setc TARGET_CPU_X86_64 := FALSE}
  133. {$setc TARGET_CPU_ARM := TRUE}
  134. {$setc TARGET_CPU_ARM64 := FALSE}
  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. {$ifc defined ios}
  147. {$setc TARGET_OS_MAC := FALSE}
  148. {$setc TARGET_OS_IPHONE := TRUE}
  149. {$setc TARGET_OS_EMBEDDED := TRUE}
  150. {$elsec}
  151. {$setc TARGET_OS_MAC := TRUE}
  152. {$setc TARGET_OS_IPHONE := FALSE}
  153. {$setc TARGET_OS_EMBEDDED := FALSE}
  154. {$endc}
  155. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  156. {$elsec}
  157. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  158. {$endc}
  159. {$ifc defined __LP64__ and __LP64__ }
  160. {$setc TARGET_CPU_64 := TRUE}
  161. {$elsec}
  162. {$setc TARGET_CPU_64 := FALSE}
  163. {$endc}
  164. {$ifc defined FPC_BIG_ENDIAN}
  165. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  166. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  167. {$elifc defined FPC_LITTLE_ENDIAN}
  168. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  169. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  170. {$elsec}
  171. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  172. {$endc}
  173. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  174. {$setc CALL_NOT_IN_CARBON := FALSE}
  175. {$setc OLDROUTINENAMES := FALSE}
  176. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  177. {$setc OPAQUE_UPP_TYPES := TRUE}
  178. {$setc OTCARBONAPPLICATION := TRUE}
  179. {$setc OTKERNEL := FALSE}
  180. {$setc PM_USE_SESSION_APIS := TRUE}
  181. {$setc TARGET_API_MAC_CARBON := TRUE}
  182. {$setc TARGET_API_MAC_OS8 := FALSE}
  183. {$setc TARGET_API_MAC_OSX := TRUE}
  184. {$setc TARGET_CARBON := TRUE}
  185. {$setc TARGET_CPU_68K := FALSE}
  186. {$setc TARGET_CPU_MIPS := FALSE}
  187. {$setc TARGET_CPU_SPARC := FALSE}
  188. {$setc TARGET_OS_UNIX := FALSE}
  189. {$setc TARGET_OS_WIN32 := FALSE}
  190. {$setc TARGET_RT_MAC_68881 := FALSE}
  191. {$setc TARGET_RT_MAC_CFM := FALSE}
  192. {$setc TARGET_RT_MAC_MACHO := TRUE}
  193. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  194. {$setc TYPE_BOOL := FALSE}
  195. {$setc TYPE_EXTENDED := FALSE}
  196. {$setc TYPE_LONGLONG := TRUE}
  197. uses MacTypes,TextCommon;
  198. {$endc} {not MACOSALLINCLUDE}
  199. {$ifc TARGET_OS_MAC}
  200. {$ALIGN MAC68K}
  201. { Unicode conversion contexts: }
  202. type
  203. TextToUnicodeInfo = ^SInt32; { an opaque type }
  204. TextToUnicodeInfoPtr = ^TextToUnicodeInfo; { when a var xx:TextToUnicodeInfo parameter can be nil, it is changed to xx: TextToUnicodeInfoPtr }
  205. UnicodeToTextInfo = ^SInt32; { an opaque type }
  206. UnicodeToTextInfoPtr = ^UnicodeToTextInfo; { when a var xx:UnicodeToTextInfo parameter can be nil, it is changed to xx: UnicodeToTextInfoPtr }
  207. UnicodeToTextRunInfo = ^SInt32; { an opaque type }
  208. UnicodeToTextRunInfoPtr = ^UnicodeToTextRunInfo; { when a var xx:UnicodeToTextRunInfo parameter can be nil, it is changed to xx: UnicodeToTextRunInfoPtr }
  209. ConstTextToUnicodeInfo = TextToUnicodeInfo;
  210. ConstUnicodeToTextInfo = UnicodeToTextInfo;
  211. { UnicodeMapVersion type & values }
  212. type
  213. UnicodeMapVersion = SInt32;
  214. const
  215. kUnicodeUseLatestMapping = -1;
  216. kUnicodeUseHFSPlusMapping = 4;
  217. { Types used in conversion }
  218. type
  219. UnicodeMapping = record
  220. unicodeEncoding: TextEncoding;
  221. otherEncoding: TextEncoding;
  222. mappingVersion: UnicodeMapVersion;
  223. end;
  224. UnicodeMappingPtr = ^UnicodeMapping;
  225. type
  226. ConstUnicodeMappingPtr = ^UnicodeMapping;
  227. { Control flags for ConvertFromUnicodeToText and ConvertFromTextToUnicode }
  228. const
  229. kUnicodeUseFallbacksBit = 0;
  230. kUnicodeKeepInfoBit = 1;
  231. kUnicodeDirectionalityBits = 2;
  232. kUnicodeVerticalFormBit = 4;
  233. kUnicodeLooseMappingsBit = 5;
  234. kUnicodeStringUnterminatedBit = 6;
  235. kUnicodeTextRunBit = 7;
  236. kUnicodeKeepSameEncodingBit = 8;
  237. kUnicodeForceASCIIRangeBit = 9;
  238. kUnicodeNoHalfwidthCharsBit = 10;
  239. kUnicodeTextRunHeuristicsBit = 11;
  240. kUnicodeMapLineFeedToReturnBit = 12; { if kUnicodeUseExternalEncodingFormBit is not set, }
  241. { input/output UTF-16 (and UTF-32) is assumed to be in native endian. }
  242. { if kUnicodeUseExternalEncodingFormBit is set, }
  243. { input UTF-16 (and UTF-32) is assumed to be in big endian }
  244. { unless it begins with a byte-order-mark, }
  245. { and output UTF-16 (and UTF-32) will be in big endian. }
  246. kUnicodeUseExternalEncodingFormBit = 13; { Bits 16-17 are defined in TextEncodingConverter.h for TECSetBasicOptions }
  247. const
  248. kUnicodeUseFallbacksMask = 1 shl kUnicodeUseFallbacksBit;
  249. kUnicodeKeepInfoMask = 1 shl kUnicodeKeepInfoBit;
  250. kUnicodeDirectionalityMask = 3 shl kUnicodeDirectionalityBits;
  251. kUnicodeVerticalFormMask = 1 shl kUnicodeVerticalFormBit;
  252. kUnicodeLooseMappingsMask = 1 shl kUnicodeLooseMappingsBit;
  253. kUnicodeStringUnterminatedMask = 1 shl kUnicodeStringUnterminatedBit;
  254. kUnicodeTextRunMask = 1 shl kUnicodeTextRunBit;
  255. kUnicodeKeepSameEncodingMask = 1 shl kUnicodeKeepSameEncodingBit;
  256. kUnicodeForceASCIIRangeMask = 1 shl kUnicodeForceASCIIRangeBit;
  257. kUnicodeNoHalfwidthCharsMask = 1 shl kUnicodeNoHalfwidthCharsBit;
  258. kUnicodeTextRunHeuristicsMask = 1 shl kUnicodeTextRunHeuristicsBit;
  259. kUnicodeMapLineFeedToReturnMask = 1 shl kUnicodeMapLineFeedToReturnBit; { if kUnicodeUseExternalEncodingFormBit is not set, }
  260. { input/output UTF-16 (and UTF-32) is assumed to be in native endian. }
  261. { if kUnicodeUseExternalEncodingFormBit is set, }
  262. { input UTF-16 (and UTF-32) is assumed to be in big endian }
  263. { unless it begins with a byte-order-mark, }
  264. { and output UTF-16 (and UTF-32) will be in big endian. }
  265. kUnicodeUseExternalEncodingFormMask = 1 shl kUnicodeUseExternalEncodingFormBit;
  266. { Values for kUnicodeDirectionality field }
  267. const
  268. kUnicodeDefaultDirection = 0;
  269. kUnicodeLeftToRight = 1;
  270. kUnicodeRightToLeft = 2;
  271. { Directionality masks for control flags }
  272. const
  273. kUnicodeDefaultDirectionMask = kUnicodeDefaultDirection shl kUnicodeDirectionalityBits;
  274. kUnicodeLeftToRightMask = kUnicodeLeftToRight shl kUnicodeDirectionalityBits;
  275. kUnicodeRightToLeftMask = kUnicodeRightToLeft shl kUnicodeDirectionalityBits;
  276. { Control flags for TruncateForUnicodeToText: }
  277. {
  278. Now TruncateForUnicodeToText uses control flags from the same set as used by
  279. ConvertFromTextToUnicode, ConvertFromUnicodeToText, etc., but only
  280. kUnicodeStringUnterminatedMask is meaningful for TruncateForUnicodeToText.
  281. Previously two special control flags were defined for TruncateForUnicodeToText:
  282. kUnicodeTextElementSafeBit = 0
  283. kUnicodeRestartSafeBit = 1
  284. However, neither of these was implemented.
  285. Instead of implementing kUnicodeTextElementSafeBit, we now use
  286. kUnicodeStringUnterminatedMask since it accomplishes the same thing and avoids
  287. having special flags just for TruncateForUnicodeToText
  288. Also, kUnicodeRestartSafeBit is unnecessary, since restart-safeness is handled by
  289. setting kUnicodeKeepInfoBit with ConvertFromUnicodeToText.
  290. If TruncateForUnicodeToText is called with one or both of the old special control
  291. flags set (bits 0 or 1), it will not generate a paramErr, but the old bits have no
  292. effect on its operation.
  293. }
  294. { Filter bits for filter field in QueryUnicodeMappings and CountUnicodeMappings: }
  295. const
  296. kUnicodeMatchUnicodeBaseBit = 0;
  297. kUnicodeMatchUnicodeVariantBit = 1;
  298. kUnicodeMatchUnicodeFormatBit = 2;
  299. kUnicodeMatchOtherBaseBit = 3;
  300. kUnicodeMatchOtherVariantBit = 4;
  301. kUnicodeMatchOtherFormatBit = 5;
  302. const
  303. kUnicodeMatchUnicodeBaseMask = 1 shl kUnicodeMatchUnicodeBaseBit;
  304. kUnicodeMatchUnicodeVariantMask = 1 shl kUnicodeMatchUnicodeVariantBit;
  305. kUnicodeMatchUnicodeFormatMask = 1 shl kUnicodeMatchUnicodeFormatBit;
  306. kUnicodeMatchOtherBaseMask = 1 shl kUnicodeMatchOtherBaseBit;
  307. kUnicodeMatchOtherVariantMask = 1 shl kUnicodeMatchOtherVariantBit;
  308. kUnicodeMatchOtherFormatMask = 1 shl kUnicodeMatchOtherFormatBit;
  309. { Control flags for SetFallbackUnicodeToText }
  310. const
  311. kUnicodeFallbackSequencingBits = 0;
  312. const
  313. kUnicodeFallbackSequencingMask = 3 shl kUnicodeFallbackSequencingBits;
  314. kUnicodeFallbackInterruptSafeMask = 1 shl 2; { To indicate that caller fallback routine doesnÕt move memory}
  315. { values for kUnicodeFallbackSequencing field }
  316. const
  317. kUnicodeFallbackDefaultOnly = 0;
  318. kUnicodeFallbackCustomOnly = 1;
  319. kUnicodeFallbackDefaultFirst = 2;
  320. kUnicodeFallbackCustomFirst = 3;
  321. { Caller-supplied entry point to a fallback handler }
  322. type
  323. UnicodeToTextFallbackProcPtr = function( iSrcUniStr: UniCharPtr; iSrcUniStrLen: ByteCount; var oSrcConvLen: ByteCount; oDestStr: TextPtr; iDestStrLen: ByteCount; var oDestConvLen: ByteCount; iInfoPtr: LogicalAddress; iUnicodeMappingPtr: ConstUnicodeMappingPtr ): OSStatus;
  324. UnicodeToTextFallbackUPP = UnicodeToTextFallbackProcPtr;
  325. {
  326. * NewUnicodeToTextFallbackUPP()
  327. *
  328. * Availability:
  329. * Mac OS X: in version 10.0 and later in CoreServices.framework
  330. * CarbonLib: in CarbonLib 1.0 and later
  331. * Non-Carbon CFM: available as macro/inline
  332. }
  333. function NewUnicodeToTextFallbackUPP( userRoutine: UnicodeToTextFallbackProcPtr ): UnicodeToTextFallbackUPP; external name '_NewUnicodeToTextFallbackUPP';
  334. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  335. {
  336. * DisposeUnicodeToTextFallbackUPP()
  337. *
  338. * Availability:
  339. * Mac OS X: in version 10.0 and later in CoreServices.framework
  340. * CarbonLib: in CarbonLib 1.0 and later
  341. * Non-Carbon CFM: available as macro/inline
  342. }
  343. procedure DisposeUnicodeToTextFallbackUPP( userUPP: UnicodeToTextFallbackUPP ); external name '_DisposeUnicodeToTextFallbackUPP';
  344. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  345. {
  346. * InvokeUnicodeToTextFallbackUPP()
  347. *
  348. * Availability:
  349. * Mac OS X: in version 10.0 and later in CoreServices.framework
  350. * CarbonLib: in CarbonLib 1.0 and later
  351. * Non-Carbon CFM: available as macro/inline
  352. }
  353. function InvokeUnicodeToTextFallbackUPP( iSrcUniStr: UniCharPtr; iSrcUniStrLen: ByteCount; var oSrcConvLen: ByteCount; oDestStr: TextPtr; iDestStrLen: ByteCount; var oDestConvLen: ByteCount; iInfoPtr: LogicalAddress; iUnicodeMappingPtr: ConstUnicodeMappingPtr; userUPP: UnicodeToTextFallbackUPP ): OSStatus; external name '_InvokeUnicodeToTextFallbackUPP';
  354. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  355. { Function prototypes }
  356. {
  357. * CreateTextToUnicodeInfo()
  358. *
  359. * Availability:
  360. * Mac OS X: in version 10.0 and later in CoreServices.framework
  361. * CarbonLib: in CarbonLib 1.0 and later
  362. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  363. }
  364. function CreateTextToUnicodeInfo( iUnicodeMapping: ConstUnicodeMappingPtr; var oTextToUnicodeInfo: TextToUnicodeInfo ): OSStatus; external name '_CreateTextToUnicodeInfo';
  365. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  366. {
  367. * CreateTextToUnicodeInfoByEncoding()
  368. *
  369. * Availability:
  370. * Mac OS X: in version 10.0 and later in CoreServices.framework
  371. * CarbonLib: in CarbonLib 1.0 and later
  372. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  373. }
  374. function CreateTextToUnicodeInfoByEncoding( iEncoding: TextEncoding; var oTextToUnicodeInfo: TextToUnicodeInfo ): OSStatus; external name '_CreateTextToUnicodeInfoByEncoding';
  375. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  376. {
  377. * CreateUnicodeToTextInfo()
  378. *
  379. * Availability:
  380. * Mac OS X: in version 10.0 and later in CoreServices.framework
  381. * CarbonLib: in CarbonLib 1.0 and later
  382. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  383. }
  384. function CreateUnicodeToTextInfo( iUnicodeMapping: ConstUnicodeMappingPtr; var oUnicodeToTextInfo: UnicodeToTextInfo ): OSStatus; external name '_CreateUnicodeToTextInfo';
  385. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  386. {
  387. * CreateUnicodeToTextInfoByEncoding()
  388. *
  389. * Availability:
  390. * Mac OS X: in version 10.0 and later in CoreServices.framework
  391. * CarbonLib: in CarbonLib 1.0 and later
  392. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  393. }
  394. function CreateUnicodeToTextInfoByEncoding( iEncoding: TextEncoding; var oUnicodeToTextInfo: UnicodeToTextInfo ): OSStatus; external name '_CreateUnicodeToTextInfoByEncoding';
  395. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  396. {
  397. * CreateUnicodeToTextRunInfo()
  398. *
  399. * Availability:
  400. * Mac OS X: in version 10.0 and later in CoreServices.framework
  401. * CarbonLib: in CarbonLib 1.0 and later
  402. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  403. }
  404. function CreateUnicodeToTextRunInfo( iNumberOfMappings: ItemCount; {const} iUnicodeMappings: {variable-size-array} UnicodeMappingPtr; var oUnicodeToTextInfo: UnicodeToTextRunInfo ): OSStatus; external name '_CreateUnicodeToTextRunInfo';
  405. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  406. {
  407. * CreateUnicodeToTextRunInfoByEncoding()
  408. *
  409. * Availability:
  410. * Mac OS X: in version 10.0 and later in CoreServices.framework
  411. * CarbonLib: in CarbonLib 1.0 and later
  412. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  413. }
  414. function CreateUnicodeToTextRunInfoByEncoding( iNumberOfEncodings: ItemCount; {const} iEncodings: {variable-size-array} TextEncodingPtr; var oUnicodeToTextInfo: UnicodeToTextRunInfo ): OSStatus; external name '_CreateUnicodeToTextRunInfoByEncoding';
  415. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  416. {
  417. * CreateUnicodeToTextRunInfoByScriptCode()
  418. *
  419. * Availability:
  420. * Mac OS X: in version 10.0 and later in CoreServices.framework
  421. * CarbonLib: in CarbonLib 1.0 and later
  422. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  423. }
  424. function CreateUnicodeToTextRunInfoByScriptCode( iNumberOfScriptCodes: ItemCount; {const} iScripts: {variable-size-array} ScriptCodePtr; var oUnicodeToTextInfo: UnicodeToTextRunInfo ): OSStatus; external name '_CreateUnicodeToTextRunInfoByScriptCode';
  425. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  426. { Change the TextToUnicodeInfo to another mapping. }
  427. {
  428. * ChangeTextToUnicodeInfo()
  429. *
  430. * Availability:
  431. * Mac OS X: in version 10.0 and later in CoreServices.framework
  432. * CarbonLib: in CarbonLib 1.0 and later
  433. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  434. }
  435. function ChangeTextToUnicodeInfo( ioTextToUnicodeInfo: TextToUnicodeInfo; iUnicodeMapping: ConstUnicodeMappingPtr ): OSStatus; external name '_ChangeTextToUnicodeInfo';
  436. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  437. { Change the UnicodeToTextInfo to another mapping. }
  438. {
  439. * ChangeUnicodeToTextInfo()
  440. *
  441. * Availability:
  442. * Mac OS X: in version 10.0 and later in CoreServices.framework
  443. * CarbonLib: in CarbonLib 1.0 and later
  444. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  445. }
  446. function ChangeUnicodeToTextInfo( ioUnicodeToTextInfo: UnicodeToTextInfo; iUnicodeMapping: ConstUnicodeMappingPtr ): OSStatus; external name '_ChangeUnicodeToTextInfo';
  447. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  448. {
  449. * DisposeTextToUnicodeInfo()
  450. *
  451. * Availability:
  452. * Mac OS X: in version 10.0 and later in CoreServices.framework
  453. * CarbonLib: in CarbonLib 1.0 and later
  454. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  455. }
  456. function DisposeTextToUnicodeInfo( var ioTextToUnicodeInfo: TextToUnicodeInfo ): OSStatus; external name '_DisposeTextToUnicodeInfo';
  457. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  458. {
  459. * DisposeUnicodeToTextInfo()
  460. *
  461. * Availability:
  462. * Mac OS X: in version 10.0 and later in CoreServices.framework
  463. * CarbonLib: in CarbonLib 1.0 and later
  464. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  465. }
  466. function DisposeUnicodeToTextInfo( var ioUnicodeToTextInfo: UnicodeToTextInfo ): OSStatus; external name '_DisposeUnicodeToTextInfo';
  467. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  468. {
  469. * DisposeUnicodeToTextRunInfo()
  470. *
  471. * Availability:
  472. * Mac OS X: in version 10.0 and later in CoreServices.framework
  473. * CarbonLib: in CarbonLib 1.0 and later
  474. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  475. }
  476. function DisposeUnicodeToTextRunInfo( var ioUnicodeToTextRunInfo: UnicodeToTextRunInfo ): OSStatus; external name '_DisposeUnicodeToTextRunInfo';
  477. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  478. {
  479. * ConvertFromTextToUnicode()
  480. *
  481. * Availability:
  482. * Mac OS X: in version 10.0 and later in CoreServices.framework
  483. * CarbonLib: in CarbonLib 1.0 and later
  484. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  485. }
  486. function ConvertFromTextToUnicode( iTextToUnicodeInfo: TextToUnicodeInfo; iSourceLen: ByteCount; iSourceStr: ConstLogicalAddress; iControlFlags: OptionBits; iOffsetCount: ItemCount; {const} iOffsetArray: {variable-size-array} ByteOffsetPtr { can be NULL }; oOffsetCount: ItemCountPtr { can be NULL }; oOffsetArray: {variable-size-array} ByteOffsetPtr { can be NULL }; iOutputBufLen: ByteCount; var oSourceRead: ByteCount; var oUnicodeLen: ByteCount; oUnicodeStr: {variable-size-array} UniCharPtr ): OSStatus; external name '_ConvertFromTextToUnicode';
  487. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  488. {
  489. * ConvertFromUnicodeToText()
  490. *
  491. * Availability:
  492. * Mac OS X: in version 10.0 and later in CoreServices.framework
  493. * CarbonLib: in CarbonLib 1.0 and later
  494. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  495. }
  496. function ConvertFromUnicodeToText( iUnicodeToTextInfo: UnicodeToTextInfo; iUnicodeLen: ByteCount; {const} iUnicodeStr: {variable-size-array} UniCharPtr; iControlFlags: OptionBits; iOffsetCount: ItemCount; {const} iOffsetArray: {variable-size-array} ByteOffsetPtr { can be NULL }; oOffsetCount: ItemCountPtr { can be NULL }; oOffsetArray: {variable-size-array} ByteOffsetPtr { can be NULL }; iOutputBufLen: ByteCount; var oInputRead: ByteCount; var oOutputLen: ByteCount; oOutputStr: LogicalAddress ): OSStatus; external name '_ConvertFromUnicodeToText';
  497. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  498. {
  499. * ConvertFromUnicodeToTextRun()
  500. *
  501. * Availability:
  502. * Mac OS X: in version 10.0 and later in CoreServices.framework
  503. * CarbonLib: in CarbonLib 1.0 and later
  504. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  505. }
  506. function ConvertFromUnicodeToTextRun( iUnicodeToTextInfo: UnicodeToTextRunInfo; iUnicodeLen: ByteCount; {const} iUnicodeStr: {variable-size-array} UniCharPtr; iControlFlags: OptionBits; iOffsetCount: ItemCount; {const} iOffsetArray: {variable-size-array} ByteOffsetPtr { can be NULL }; oOffsetCount: ItemCountPtr { can be NULL }; oOffsetArray: {variable-size-array} ByteOffsetPtr { can be NULL }; iOutputBufLen: ByteCount; var oInputRead: ByteCount; var oOutputLen: ByteCount; oOutputStr: LogicalAddress; iEncodingRunBufLen: ItemCount; var oEncodingRunOutLen: ItemCount; oEncodingRuns: {variable-size-array} TextEncodingRunPtr ): OSStatus; external name '_ConvertFromUnicodeToTextRun';
  507. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  508. {
  509. * ConvertFromUnicodeToScriptCodeRun()
  510. *
  511. * Availability:
  512. * Mac OS X: in version 10.0 and later in CoreServices.framework
  513. * CarbonLib: in CarbonLib 1.0 and later
  514. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  515. }
  516. function ConvertFromUnicodeToScriptCodeRun( iUnicodeToTextInfo: UnicodeToTextRunInfo; iUnicodeLen: ByteCount; {const} iUnicodeStr: {variable-size-array} UniCharPtr; iControlFlags: OptionBits; iOffsetCount: ItemCount; {const} iOffsetArray: {variable-size-array} ByteOffsetPtr { can be NULL }; oOffsetCount: ItemCountPtr { can be NULL }; oOffsetArray: {variable-size-array} ByteOffsetPtr { can be NULL }; iOutputBufLen: ByteCount; var oInputRead: ByteCount; var oOutputLen: ByteCount; oOutputStr: LogicalAddress; iScriptRunBufLen: ItemCount; var oScriptRunOutLen: ItemCount; oScriptCodeRuns: {variable-size-array} ScriptCodeRunPtr ): OSStatus; external name '_ConvertFromUnicodeToScriptCodeRun';
  517. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  518. { Truncate a multibyte string at a safe place. }
  519. {
  520. * TruncateForTextToUnicode()
  521. *
  522. * Availability:
  523. * Mac OS X: in version 10.0 and later in CoreServices.framework
  524. * CarbonLib: in CarbonLib 1.0 and later
  525. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  526. }
  527. function TruncateForTextToUnicode( iTextToUnicodeInfo: ConstTextToUnicodeInfo; iSourceLen: ByteCount; iSourceStr: ConstLogicalAddress; iMaxLen: ByteCount; var oTruncatedLen: ByteCount ): OSStatus; external name '_TruncateForTextToUnicode';
  528. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  529. { Truncate a Unicode string at a safe place. }
  530. {
  531. * TruncateForUnicodeToText()
  532. *
  533. * Availability:
  534. * Mac OS X: in version 10.0 and later in CoreServices.framework
  535. * CarbonLib: in CarbonLib 1.0 and later
  536. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  537. }
  538. function TruncateForUnicodeToText( iUnicodeToTextInfo: ConstUnicodeToTextInfo; iSourceLen: ByteCount; iSourceStr: ConstUniCharPtr; iControlFlags: OptionBits; iMaxLen: ByteCount; var oTruncatedLen: ByteCount ): OSStatus; external name '_TruncateForUnicodeToText';
  539. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  540. { Convert a Pascal string to Unicode string. }
  541. {
  542. * ConvertFromPStringToUnicode()
  543. *
  544. * Availability:
  545. * Mac OS X: in version 10.0 and later in CoreServices.framework
  546. * CarbonLib: in CarbonLib 1.0 and later
  547. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  548. }
  549. function ConvertFromPStringToUnicode( iTextToUnicodeInfo: TextToUnicodeInfo; const (*var*) iPascalStr: Str255; iOutputBufLen: ByteCount; var oUnicodeLen: ByteCount; oUnicodeStr: UniCharPtr ): OSStatus; external name '_ConvertFromPStringToUnicode';
  550. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  551. { Convert a Unicode string to Pascal string. }
  552. {
  553. * ConvertFromUnicodeToPString()
  554. *
  555. * Availability:
  556. * Mac OS X: in version 10.0 and later in CoreServices.framework
  557. * CarbonLib: in CarbonLib 1.0 and later
  558. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  559. }
  560. function ConvertFromUnicodeToPString( iUnicodeToTextInfo: UnicodeToTextInfo; iUnicodeLen: ByteCount; {const} iUnicodeStr: {variable-size-array} UniCharPtr; var oPascalStr: Str255 ): OSStatus; external name '_ConvertFromUnicodeToPString';
  561. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  562. { Count the available conversion mappings. }
  563. {
  564. * CountUnicodeMappings()
  565. *
  566. * Availability:
  567. * Mac OS X: in version 10.0 and later in CoreServices.framework
  568. * CarbonLib: in CarbonLib 1.0 and later
  569. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  570. }
  571. function CountUnicodeMappings( iFilter: OptionBits; iFindMapping: ConstUnicodeMappingPtr; var oActualCount: ItemCount ): OSStatus; external name '_CountUnicodeMappings';
  572. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  573. { Get a list of the available conversion mappings. }
  574. {
  575. * QueryUnicodeMappings()
  576. *
  577. * Availability:
  578. * Mac OS X: in version 10.0 and later in CoreServices.framework
  579. * CarbonLib: in CarbonLib 1.0 and later
  580. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  581. }
  582. function QueryUnicodeMappings( iFilter: OptionBits; iFindMapping: ConstUnicodeMappingPtr; iMaxCount: ItemCount; var oActualCount: ItemCount; oReturnedMappings: {variable-size-array} UnicodeMappingPtr ): OSStatus; external name '_QueryUnicodeMappings';
  583. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  584. { Setup the fallback handler for converting Unicode To Text. }
  585. {
  586. * SetFallbackUnicodeToText()
  587. *
  588. * Availability:
  589. * Mac OS X: in version 10.0 and later in CoreServices.framework
  590. * CarbonLib: in CarbonLib 1.0 and later
  591. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  592. }
  593. function SetFallbackUnicodeToText( iUnicodeToTextInfo: UnicodeToTextInfo; iFallback: UnicodeToTextFallbackUPP; iControlFlags: OptionBits; iInfoPtr: LogicalAddress ): OSStatus; external name '_SetFallbackUnicodeToText';
  594. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  595. { Setup the fallback handler for converting Unicode To TextRuns. }
  596. {
  597. * SetFallbackUnicodeToTextRun()
  598. *
  599. * Availability:
  600. * Mac OS X: in version 10.0 and later in CoreServices.framework
  601. * CarbonLib: in CarbonLib 1.0 and later
  602. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  603. }
  604. function SetFallbackUnicodeToTextRun( iUnicodeToTextRunInfo: UnicodeToTextRunInfo; iFallback: UnicodeToTextFallbackUPP; iControlFlags: OptionBits; iInfoPtr: LogicalAddress ): OSStatus; external name '_SetFallbackUnicodeToTextRun';
  605. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  606. { Re-initialize all state information kept by the context objects. }
  607. {
  608. * ResetTextToUnicodeInfo()
  609. *
  610. * Availability:
  611. * Mac OS X: in version 10.0 and later in CoreServices.framework
  612. * CarbonLib: in CarbonLib 1.0 and later
  613. * Non-Carbon CFM: in UnicodeConverter 1.3 and later
  614. }
  615. function ResetTextToUnicodeInfo( ioTextToUnicodeInfo: TextToUnicodeInfo ): OSStatus; external name '_ResetTextToUnicodeInfo';
  616. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  617. { Re-initialize all state information kept by the context objects. }
  618. {
  619. * ResetUnicodeToTextInfo()
  620. *
  621. * Availability:
  622. * Mac OS X: in version 10.0 and later in CoreServices.framework
  623. * CarbonLib: in CarbonLib 1.0 and later
  624. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  625. }
  626. function ResetUnicodeToTextInfo( ioUnicodeToTextInfo: UnicodeToTextInfo ): OSStatus; external name '_ResetUnicodeToTextInfo';
  627. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  628. { Re-initialize all state information kept by the context objects in TextRun conversions. }
  629. {
  630. * ResetUnicodeToTextRunInfo()
  631. *
  632. * Availability:
  633. * Mac OS X: in version 10.0 and later in CoreServices.framework
  634. * CarbonLib: in CarbonLib 1.0 and later
  635. * Non-Carbon CFM: in UnicodeConverter 1.1 and later
  636. }
  637. function ResetUnicodeToTextRunInfo( ioUnicodeToTextRunInfo: UnicodeToTextRunInfo ): OSStatus; external name '_ResetUnicodeToTextRunInfo';
  638. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  639. {$endc} {TARGET_OS_MAC}
  640. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  641. end.
  642. {$endc} {not MACOSALLINCLUDE}