00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _TEXTMGR_H_
00014 #define _TEXTMGR_H_
00015
00016 #include <PalmTypes.h>
00017 #include <Chars.h>
00018
00019
00020
00021
00022
00023 typedef uint16_t CharEncodingType;
00024
00025
00026 #define maxEncodingNameLength 40
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #define CHAR_ENCODING_VALUE(value) ((CharEncodingType)value)
00040
00041
00042 #define charEncodingUnknown CHAR_ENCODING_VALUE(0)
00043
00044
00045 #define charEncodingMax CHAR_ENCODING_VALUE(91)
00046
00047
00048
00049 #define charEncodingPalmGSM CHAR_ENCODING_VALUE(78)
00050
00051 #define charEncodingPalmLatin CHAR_ENCODING_VALUE(3)
00052
00053 #define charEncodingCP1252 CHAR_ENCODING_VALUE(7)
00054
00055 #define charEncodingISO8859_1 CHAR_ENCODING_VALUE(2)
00056
00057 #define charEncodingAscii CHAR_ENCODING_VALUE(1)
00058
00059
00060
00061 #define charEncodingPalmSJIS CHAR_ENCODING_VALUE(5)
00062
00063 #define charEncodingCP932 CHAR_ENCODING_VALUE(8)
00064
00065 #define charEncodingShiftJIS CHAR_ENCODING_VALUE(4)
00066
00067
00068 #define charEncodingUCS2 CHAR_ENCODING_VALUE(9)
00069 #define charEncodingUTF8 CHAR_ENCODING_VALUE(6)
00070 #define charEncodingUTF7 CHAR_ENCODING_VALUE(24)
00071 #define charEncodingUTF16 CHAR_ENCODING_VALUE(75)
00072 #define charEncodingUTF16BE CHAR_ENCODING_VALUE(76)
00073 #define charEncodingUTF16LE CHAR_ENCODING_VALUE(77)
00074 #define charEncodingUTF32 CHAR_ENCODING_VALUE(84)
00075 #define charEncodingUTF32BE CHAR_ENCODING_VALUE(85)
00076 #define charEncodingUTF32LE CHAR_ENCODING_VALUE(86)
00077 #define charEncodingUTF7_IMAP CHAR_ENCODING_VALUE(87)
00078 #define charEncodingUCS4 CHAR_ENCODING_VALUE(88)
00079
00080
00081 #define charEncodingCP850 CHAR_ENCODING_VALUE(12)
00082 #define charEncodingCP437 CHAR_ENCODING_VALUE(13)
00083 #define charEncodingCP865 CHAR_ENCODING_VALUE(14)
00084 #define charEncodingCP860 CHAR_ENCODING_VALUE(15)
00085 #define charEncodingCP861 CHAR_ENCODING_VALUE(16)
00086 #define charEncodingCP863 CHAR_ENCODING_VALUE(17)
00087 #define charEncodingCP775 CHAR_ENCODING_VALUE(18)
00088 #define charEncodingMacIslande CHAR_ENCODING_VALUE(19)
00089 #define charEncodingMacintosh CHAR_ENCODING_VALUE(20)
00090 #define charEncodingCP1257 CHAR_ENCODING_VALUE(21)
00091 #define charEncodingISO8859_3 CHAR_ENCODING_VALUE(22)
00092 #define charEncodingISO8859_4 CHAR_ENCODING_VALUE(23)
00093
00094
00095 #define charEncodingISO8859_2 CHAR_ENCODING_VALUE(26)
00096 #define charEncodingCP1250 CHAR_ENCODING_VALUE(27)
00097 #define charEncodingCP852 CHAR_ENCODING_VALUE(28)
00098 #define charEncodingXKamenicky CHAR_ENCODING_VALUE(29)
00099 #define charEncodingMacXCroate CHAR_ENCODING_VALUE(30)
00100 #define charEncodingMacXLat2 CHAR_ENCODING_VALUE(31)
00101 #define charEncodingMacXRomania CHAR_ENCODING_VALUE(32)
00102 #define charEncodingGSM CHAR_ENCODING_VALUE(90)
00103
00104
00105 #define charEncodingEucJp CHAR_ENCODING_VALUE(25)
00106 #define charEncodingISO2022Jp CHAR_ENCODING_VALUE(10)
00107 #define charEncodingXAutoJp CHAR_ENCODING_VALUE(11)
00108
00109
00110 #define charEncodingISO8859_7 CHAR_ENCODING_VALUE(33)
00111 #define charEncodingCP1253 CHAR_ENCODING_VALUE(34)
00112 #define charEncodingCP869 CHAR_ENCODING_VALUE(35)
00113 #define charEncodingCP737 CHAR_ENCODING_VALUE(36)
00114 #define charEncodingMacXGr CHAR_ENCODING_VALUE(37)
00115
00116
00117 #define charEncodingCP1251 CHAR_ENCODING_VALUE(38)
00118 #define charEncodingISO8859_5 CHAR_ENCODING_VALUE(39)
00119 #define charEncodingKoi8R CHAR_ENCODING_VALUE(40)
00120 #define charEncodingKoi8 CHAR_ENCODING_VALUE(41)
00121 #define charEncodingCP855 CHAR_ENCODING_VALUE(42)
00122 #define charEncodingCP866 CHAR_ENCODING_VALUE(43)
00123 #define charEncodingMacCyr CHAR_ENCODING_VALUE(44)
00124 #define charEncodingMacUkraine CHAR_ENCODING_VALUE(45)
00125
00126
00127 #define charEncodingCP1254 CHAR_ENCODING_VALUE(46)
00128 #define charEncodingISO8859_9 CHAR_ENCODING_VALUE(47)
00129 #define charEncodingCP857 CHAR_ENCODING_VALUE(48)
00130 #define charEncodingMacTurc CHAR_ENCODING_VALUE(49)
00131 #define charEncodingCP853 CHAR_ENCODING_VALUE(50)
00132
00133
00134 #define charEncodingISO8859_6 CHAR_ENCODING_VALUE(51)
00135 #define charEncodingAsmo708 CHAR_ENCODING_VALUE(52)
00136 #define charEncodingCP1256 CHAR_ENCODING_VALUE(53)
00137 #define charEncodingCP864 CHAR_ENCODING_VALUE(54)
00138 #define charEncodingAsmo708Plus CHAR_ENCODING_VALUE(55)
00139 #define charEncodingAsmo708Fr CHAR_ENCODING_VALUE(56)
00140 #define charEncodingMacAra CHAR_ENCODING_VALUE(57)
00141
00142
00143 #define charEncodingGB2312 CHAR_ENCODING_VALUE(58)
00144 #define charEncodingHZ CHAR_ENCODING_VALUE(59)
00145 #define charEncodingGBK CHAR_ENCODING_VALUE(82)
00146 #define charEncodingPalmGB CHAR_ENCODING_VALUE(83)
00147
00148
00149 #define charEncodingBig5 CHAR_ENCODING_VALUE(60)
00150 #define charEncodingBig5_HKSCS CHAR_ENCODING_VALUE(79)
00151 #define charEncodingBig5Plus CHAR_ENCODING_VALUE(80)
00152 #define charEncodingPalmBig5 CHAR_ENCODING_VALUE(81)
00153 #define charEncodingISO2022CN CHAR_ENCODING_VALUE(89)
00154
00155
00156 #define charEncodingViscii CHAR_ENCODING_VALUE(61)
00157 #define charEncodingViqr CHAR_ENCODING_VALUE(62)
00158 #define charEncodingVncii CHAR_ENCODING_VALUE(63)
00159 #define charEncodingVietnet CHAR_ENCODING_VALUE(65)
00160 #define charEncodingCP1258 CHAR_ENCODING_VALUE(66)
00161
00162
00163 #define charEncodingEucKr CHAR_ENCODING_VALUE(67) // Was charEncodingKsc5601
00164 #define charEncodingCP949 CHAR_ENCODING_VALUE(68)
00165 #define charEncodingISO2022Kr CHAR_ENCODING_VALUE(69)
00166 #define charEncodingPalmKorean CHAR_ENCODING_VALUE(91)
00167
00168
00169 #define charEncodingISO8859_8I CHAR_ENCODING_VALUE(70)
00170 #define charEncodingISO8859_8 CHAR_ENCODING_VALUE(71)
00171 #define charEncodingCP1255 CHAR_ENCODING_VALUE(72)
00172 #define charEncodingCP1255V CHAR_ENCODING_VALUE(73)
00173
00174
00175 #define charEncodingTis620 CHAR_ENCODING_VALUE(74)
00176 #define charEncodingCP874 CHAR_ENCODING_VALUE(64)
00177
00178
00179
00180
00181
00182
00183
00184
00185 #define charAttr_DO 0x00000400 // display only (never in user data)
00186 #define charAttr_XA 0x00000200 // extra alphabetic
00187 #define charAttr_XS 0x00000100 // extra space
00188 #define charAttr_BB 0x00000080 // BEL, BS, etc.
00189 #define charAttr_CN 0x00000040 // CR, FF, HT, NL, VT
00190 #define charAttr_DI 0x00000020 // '0'-'9'
00191 #define charAttr_LO 0x00000010 // 'a'-'z' and lowercase extended chars.
00192 #define charAttr_PU 0x00000008 // punctuation
00193 #define charAttr_SP 0x00000004 // space
00194 #define charAttr_UP 0x00000002 // 'A'-'Z' and uppercase extended chars.
00195 #define charAttr_XD 0x00000001 // '0'-'9', 'A'-'F', 'a'-'f'
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205 #define byteAttrFirst 0x80 // First byte of multi-byte char.
00206 #define byteAttrLast 0x40 // Last byte of multi-byte char.
00207 #define byteAttrMiddle 0x20 // Middle byte of muli-byte char.
00208 #define byteAttrSingle 0x01 // Single byte.
00209
00210
00211
00212
00213 #define byteAttrSingleLow (byteAttrSingle | byteAttrLast)
00214 #define byteAttrHighLow (byteAttrFirst | byteAttrLast)
00215
00216
00217
00218
00219 typedef uint16_t TranslitOpType;
00220
00221
00222 #define translitOpStandardBase 0 // Beginning of standard operations.
00223
00224 #define translitOpUpperCase 0
00225 #define translitOpLowerCase 1
00226 #define translitOpReserved2 2
00227 #define translitOpReserved3 3
00228
00229
00230
00231 #define translitOpCustomBase 1000 // Beginning of char-encoding specific ops.
00232
00233 #define translitOpPreprocess 0x8000 // Mask for pre-process option, where
00234
00235
00236
00237
00238 #define kTxtConvertStateSize 32
00239
00240 typedef struct {
00241 uint8_t ioSrcState[kTxtConvertStateSize];
00242 uint8_t ioDstState[kTxtConvertStateSize];
00243 } TxtConvertStateType;
00244
00245
00246 #define textSubstitutionEncoding charEncodingUTF8
00247
00248
00249 #define textSubstitutionDefaultStr "?"
00250 #define textSubstitutionDefaultLen 1
00251
00252
00253 #define charEncodingDstBestFitFlag 0x8000
00254
00255
00256
00257 #define charEncodingOnlySingleByte 0x00000001
00258 #define charEncodingHasDoubleByte 0x00000002
00259 #define charEncodingHasLigatures 0x00000004
00260 #define charEncodingRightToLeft 0x00000008
00261
00262
00263 #define textMgrExistsFlag 0x00000001 // Was intlMgrExists
00264 #define textMgrStrictFlag 0x00000002 // Was intlMgrStrict
00265 #define textMgrBestFitFlag 0x00000004 // Was intlMgrBestFit
00266 #define textMgrHighASCIIFixupFlag 0x00000008 // New in 6.2 for 68K apps only!
00267
00268
00269 #define charAttrPrint (charAttr_DI|charAttr_LO|charAttr_PU|charAttr_SP|charAttr_UP|charAttr_XA)
00270 #define charAttrSpace (charAttr_CN|charAttr_SP|charAttr_XS)
00271 #define charAttrAlNum (charAttr_DI|charAttr_LO|charAttr_UP|charAttr_XA)
00272 #define charAttrAlpha (charAttr_LO|charAttr_UP|charAttr_XA)
00273 #define charAttrCntrl (charAttr_BB|charAttr_CN)
00274 #define charAttrGraph (charAttr_DI|charAttr_LO|charAttr_PU|charAttr_UP|charAttr_XA)
00275 #define charAttrDelim (charAttr_SP|charAttr_PU)
00276
00277
00278
00279
00280
00281
00282 #define sizeOf7BitChar(c) 1
00283
00284
00285 #define maxCharBytes 4
00286
00287
00288 #define txtErrUknownTranslitOp (txtErrorClass | 1)
00289 #define txtErrTranslitOverrun (txtErrorClass | 2)
00290 #define txtErrTranslitOverflow (txtErrorClass | 3)
00291 #define txtErrConvertOverflow (txtErrorClass | 4)
00292 #define txtErrConvertUnderflow (txtErrorClass | 5)
00293 #define txtErrUnknownEncoding (txtErrorClass | 6)
00294 #define txtErrNoCharMapping (txtErrorClass | 7)
00295 #define txtErrTranslitUnderflow (txtErrorClass | 8)
00296 #define txtErrMalformedText (txtErrorClass | 9)
00297 #define txtErrUnknownEncodingFallbackCopy (txtErrorClass | 10)
00298
00299
00300
00301
00302
00303 #define TxtCharIsSpace(ch) ((TxtCharAttr(ch) & charAttrSpace) != 0)
00304 #define TxtCharIsPrint(ch) ((TxtCharAttr(ch) & charAttrPrint) != 0)
00305 #define TxtCharIsDigit(ch) ((TxtCharAttr(ch) & charAttr_DI) != 0)
00306 #define TxtCharIsAlNum(ch) ((TxtCharAttr(ch) & charAttrAlNum) != 0)
00307 #define TxtCharIsAlpha(ch) ((TxtCharAttr(ch) & charAttrAlpha) != 0)
00308 #define TxtCharIsCntrl(ch) ((TxtCharAttr(ch) & charAttrCntrl) != 0)
00309 #define TxtCharIsGraph(ch) ((TxtCharAttr(ch) & charAttrGraph) != 0)
00310 #define TxtCharIsLower(ch) ((TxtCharAttr(ch) & charAttr_LO) != 0)
00311 #define TxtCharIsPunct(ch) ((TxtCharAttr(ch) & charAttr_PU) != 0)
00312 #define TxtCharIsUpper(ch) ((TxtCharAttr(ch) & charAttr_UP) != 0)
00313 #define TxtCharIsHex(ch) ((TxtCharAttr(ch) & charAttr_XD) != 0)
00314 #define TxtCharIsDelim(ch) ((TxtCharAttr(ch) & charAttrDelim) != 0)
00315
00316
00317
00318 #define TxtCharIsHardKey(m, c) ((((m) & commandKeyMask) != 0) && \
00319 ((((c) >= hardKeyMin) && ((c) <= hardKeyMax)) || ((c) == calcChr)))
00320
00321
00322
00323 #define TxtCharIsVirtual(m, c) (((m) & commandKeyMask) != 0)
00324
00325 #define TxtPreviousCharSize(iTextP, iOffset) TxtGetPreviousChar((iTextP), (iOffset), NULL)
00326 #define TxtNextCharSize(iTextP, iOffset) TxtGetNextChar((iTextP), (iOffset), NULL)
00327
00328
00329
00330
00331
00332
00333
00334 #define TxtCharIsRockerKey(m, c) ((((m) & commandKeyMask) != 0) && \
00335 ((((c) >= vchrRockerUp) && ((c) <= vchrRockerCenter))))
00336
00337
00338
00339 #define TxtCharIsWheelKey(m, c) ((((m) & commandKeyMask) != 0) && \
00340 ((((c) >= vchrThumbWheelUp) && ((c) <= vchrThumbWheelBack))))
00341
00342
00343
00344
00345
00346 #ifdef __cplusplus
00347 extern "C" {
00348 #endif
00349
00350
00351 uint8_t TxtByteAttr(uint8_t iByte);
00352
00353
00354 uint32_t TxtCharAttr(wchar32_t iChar);
00355
00356
00357 uint32_t TxtCharXAttr(wchar32_t iChar);
00358
00359
00360
00361 size_t TxtCharSize(wchar32_t iChar);
00362
00363
00364
00365 size_t TxtGetPreviousChar(const char* iTextP, size_t iOffset, wchar32_t* oChar);
00366
00367
00368
00369 size_t TxtGetNextChar(const char* iTextP, size_t iOffset, wchar32_t* oChar);
00370
00371
00372 wchar32_t TxtGetChar(const char* iTextP, size_t iOffset);
00373
00374
00375
00376 size_t TxtSetNextChar(char* iTextP, size_t iOffset, wchar32_t iChar);
00377
00378
00379
00380
00381
00382
00383 uint16_t TxtReplaceStr(char* iStringP, size_t iMaxLen, const char* iParamStringP, uint16_t iParamNum);
00384
00385
00386
00387
00388
00389 char* TxtParamString(const char* inTemplate, const char* param0,
00390 const char* param1, const char* param2, const char* param3);
00391
00392
00393
00394
00395 wchar32_t TxtCharBounds(const char* iTextP, size_t iOffset, size_t* oCharStart, size_t* oCharEnd);
00396
00397
00398
00399 size_t TxtGetTruncationOffset(const char* iTextP, size_t iOffset);
00400
00401
00402
00403
00404
00405 Boolean TxtTruncateString( char* iDstString,
00406 const char* iSrcString,
00407 size_t iMaxLength,
00408 Boolean iAddEllipsis);
00409
00410
00411
00412
00413
00414
00415
00416
00417 size_t TxtPrepFindString(const char* iSrcTextP, size_t iSrcLen, char* oDstTextP, size_t iDstSize);
00418
00419
00420
00421
00422 Boolean TxtFindString(const char* iSrcStringP, const char* iTargetStringP,
00423 size_t* oFoundPos, size_t* oFoundLen);
00424
00425
00426
00427
00428
00429 Boolean TxtWordBounds(const char* iTextP, size_t iLength, size_t iOffset,
00430 size_t* oWordStart, size_t* oWordEnd);
00431
00432
00433
00434
00435
00436 size_t TxtGetWordWrapOffset(const char* iTextP, size_t iOffset);
00437
00438
00439
00440 CharEncodingType TxtCharEncoding(wchar32_t iChar);
00441
00442
00443
00444
00445 CharEncodingType TxtStrEncoding(const char* iStringP);
00446
00447
00448 CharEncodingType TxtMaxEncoding(CharEncodingType a, CharEncodingType b);
00449
00450
00451
00452 const char* TxtEncodingName(CharEncodingType iEncoding);
00453
00454
00455
00456 CharEncodingType TxtNameToEncoding(const char* iEncodingName);
00457
00458
00459
00460 uint32_t TxtGetEncodingFlags(CharEncodingType iEncoding);
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471 status_t TxtTransliterate(const char* iSrcTextP, size_t iSrcLength, char* oDstTextP,
00472 size_t* ioDstLength, TranslitOpType iTranslitOp);
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504 status_t TxtConvertEncoding(Boolean newConversion, TxtConvertStateType* ioStateP,
00505 const char* srcTextP, size_t* ioSrcBytes, CharEncodingType srcEncoding,
00506 char* dstTextP, size_t* ioDstBytes, CharEncodingType dstEncoding,
00507 const char* substitutionStr, size_t substitutionLen);
00508
00509
00510
00511 Boolean TxtCharIsValid(wchar32_t iChar);
00512
00513
00514
00515
00516
00517
00518
00519
00520 int16_t TxtCaselessCompare(const char* s1, size_t s1Len, size_t* s1MatchLen,
00521 const char* s2, size_t s2Len, size_t* s2MatchLen);
00522
00523
00524
00525
00526
00527
00528 int16_t TxtCompare(const char* s1, size_t s1Len, size_t* s1MatchLen,
00529 const char* s2, size_t s2Len, size_t* s2MatchLen);
00530
00531 #ifdef __cplusplus
00532 }
00533 #endif
00534
00535 #endif // _TEXTMGR_H_