OLD | NEW |
1 /* | 1 /* |
2 ****************************************************************************** | 2 ****************************************************************************** |
3 * | 3 * |
4 * Copyright (C) 2000-2013, International Business Machines | 4 * Copyright (C) 2000-2014, International Business Machines |
5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
6 * | 6 * |
7 ****************************************************************************** | 7 ****************************************************************************** |
8 * file name: ucnvmbcs.c | 8 * file name: ucnvmbcs.cpp |
9 * encoding: US-ASCII | 9 * encoding: US-ASCII |
10 * tab size: 8 (not used) | 10 * tab size: 8 (not used) |
11 * indentation:4 | 11 * indentation:4 |
12 * | 12 * |
13 * created on: 2000jul03 | 13 * created on: 2000jul03 |
14 * created by: Markus W. Scherer | 14 * created by: Markus W. Scherer |
15 * | 15 * |
16 * The current code in this file replaces the previous implementation | 16 * The current code in this file replaces the previous implementation |
17 * of conversion code from multi-byte codepages to Unicode and back. | 17 * of conversion code from multi-byte codepages to Unicode and back. |
18 * This implementation supports the following: | 18 * This implementation supports the following: |
(...skipping 30 matching lines...) Expand all Loading... |
49 #include "unicode/udata.h" | 49 #include "unicode/udata.h" |
50 #include "unicode/uset.h" | 50 #include "unicode/uset.h" |
51 #include "unicode/utf8.h" | 51 #include "unicode/utf8.h" |
52 #include "unicode/utf16.h" | 52 #include "unicode/utf16.h" |
53 #include "ucnv_bld.h" | 53 #include "ucnv_bld.h" |
54 #include "ucnvmbcs.h" | 54 #include "ucnvmbcs.h" |
55 #include "ucnv_ext.h" | 55 #include "ucnv_ext.h" |
56 #include "ucnv_cnv.h" | 56 #include "ucnv_cnv.h" |
57 #include "cmemory.h" | 57 #include "cmemory.h" |
58 #include "cstring.h" | 58 #include "cstring.h" |
59 #include "cmutex.h" | 59 #include "umutex.h" |
60 | 60 |
61 /* control optimizations according to the platform */ | 61 /* control optimizations according to the platform */ |
62 #define MBCS_UNROLL_SINGLE_TO_BMP 1 | 62 #define MBCS_UNROLL_SINGLE_TO_BMP 1 |
63 #define MBCS_UNROLL_SINGLE_FROM_BMP 0 | 63 #define MBCS_UNROLL_SINGLE_FROM_BMP 0 |
64 | 64 |
65 /* | 65 /* |
66 * _MBCSHeader versions 5.3 & 4.3 | 66 * _MBCSHeader versions 5.3 & 4.3 |
67 * (Note that the _MBCSHeader version is in addition to the converter formatVers
ion.) | 67 * (Note that the _MBCSHeader version is in addition to the converter formatVers
ion.) |
68 * | 68 * |
69 * This version is optional. Version 5 is used for incompatible data format chan
ges. | 69 * This version is optional. Version 5 is used for incompatible data format chan
ges. |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 * In version 3, stage 2 blocks may overlap by multiples of the multiplier | 352 * In version 3, stage 2 blocks may overlap by multiples of the multiplier |
353 * for compaction. | 353 * for compaction. |
354 * In version 4, stage 2 blocks (and for single-byte codepages, stage 3 blocks) | 354 * In version 4, stage 2 blocks (and for single-byte codepages, stage 3 blocks) |
355 * may overlap by any number of entries. | 355 * may overlap by any number of entries. |
356 * | 356 * |
357 * MBCS version 2 added: | 357 * MBCS version 2 added: |
358 * the converter checks for known output types, which allows | 358 * the converter checks for known output types, which allows |
359 * adding new ones without crashing an unaware converter | 359 * adding new ones without crashing an unaware converter |
360 */ | 360 */ |
361 | 361 |
362 static const UConverterImpl _SBCSUTF8Impl; | 362 /** |
363 static const UConverterImpl _DBCSUTF8Impl; | 363 * Callback from ucnv_MBCSEnumToUnicode(), takes 32 mappings from |
| 364 * consecutive sequences of bytes, starting from the one encoded in value, |
| 365 * to Unicode code points. (Multiple mappings to reduce per-function call overhe
ad.) |
| 366 * Does not currently support m:n mappings or reverse fallbacks. |
| 367 * This function will not be called for sequences of bytes with leading zeros. |
| 368 * |
| 369 * @param context an opaque pointer, as passed into ucnv_MBCSEnumToUnicode() |
| 370 * @param value contains 1..4 bytes of the first byte sequence, right-aligned |
| 371 * @param codePoints resulting Unicode code points, or negative if a byte sequen
ce does |
| 372 * not map to anything |
| 373 * @return TRUE to continue enumeration, FALSE to stop |
| 374 */ |
| 375 typedef UBool U_CALLCONV |
| 376 UConverterEnumToUCallback(const void *context, uint32_t value, UChar32 codePoint
s[32]); |
| 377 |
| 378 static void |
| 379 ucnv_MBCSLoad(UConverterSharedData *sharedData, |
| 380 UConverterLoadArgs *pArgs, |
| 381 const uint8_t *raw, |
| 382 UErrorCode *pErrorCode); |
| 383 |
| 384 static void |
| 385 ucnv_MBCSUnload(UConverterSharedData *sharedData); |
| 386 |
| 387 static void |
| 388 ucnv_MBCSOpen(UConverter *cnv, |
| 389 UConverterLoadArgs *pArgs, |
| 390 UErrorCode *pErrorCode); |
| 391 |
| 392 static UChar32 |
| 393 ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs, |
| 394 UErrorCode *pErrorCode); |
| 395 |
| 396 static void |
| 397 ucnv_MBCSGetStarters(const UConverter* cnv, |
| 398 UBool starters[256], |
| 399 UErrorCode *pErrorCode); |
| 400 |
| 401 static const char * |
| 402 ucnv_MBCSGetName(const UConverter *cnv); |
| 403 |
| 404 static void |
| 405 ucnv_MBCSWriteSub(UConverterFromUnicodeArgs *pArgs, |
| 406 int32_t offsetIndex, |
| 407 UErrorCode *pErrorCode); |
| 408 |
| 409 static UChar32 |
| 410 ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs, |
| 411 UErrorCode *pErrorCode); |
| 412 |
| 413 static void |
| 414 ucnv_SBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs, |
| 415 UConverterToUnicodeArgs *pToUArgs, |
| 416 UErrorCode *pErrorCode); |
| 417 |
| 418 static void |
| 419 ucnv_MBCSGetUnicodeSet(const UConverter *cnv, |
| 420 const USetAdder *sa, |
| 421 UConverterUnicodeSet which, |
| 422 UErrorCode *pErrorCode); |
| 423 |
| 424 static void |
| 425 ucnv_DBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs, |
| 426 UConverterToUnicodeArgs *pToUArgs, |
| 427 UErrorCode *pErrorCode); |
| 428 |
| 429 static const UConverterImpl _SBCSUTF8Impl={ |
| 430 UCNV_MBCS, |
| 431 |
| 432 ucnv_MBCSLoad, |
| 433 ucnv_MBCSUnload, |
| 434 |
| 435 ucnv_MBCSOpen, |
| 436 NULL, |
| 437 NULL, |
| 438 |
| 439 ucnv_MBCSToUnicodeWithOffsets, |
| 440 ucnv_MBCSToUnicodeWithOffsets, |
| 441 ucnv_MBCSFromUnicodeWithOffsets, |
| 442 ucnv_MBCSFromUnicodeWithOffsets, |
| 443 ucnv_MBCSGetNextUChar, |
| 444 |
| 445 ucnv_MBCSGetStarters, |
| 446 ucnv_MBCSGetName, |
| 447 ucnv_MBCSWriteSub, |
| 448 NULL, |
| 449 ucnv_MBCSGetUnicodeSet, |
| 450 |
| 451 NULL, |
| 452 ucnv_SBCSFromUTF8 |
| 453 }; |
| 454 |
| 455 static const UConverterImpl _DBCSUTF8Impl={ |
| 456 UCNV_MBCS, |
| 457 |
| 458 ucnv_MBCSLoad, |
| 459 ucnv_MBCSUnload, |
| 460 |
| 461 ucnv_MBCSOpen, |
| 462 NULL, |
| 463 NULL, |
| 464 |
| 465 ucnv_MBCSToUnicodeWithOffsets, |
| 466 ucnv_MBCSToUnicodeWithOffsets, |
| 467 ucnv_MBCSFromUnicodeWithOffsets, |
| 468 ucnv_MBCSFromUnicodeWithOffsets, |
| 469 ucnv_MBCSGetNextUChar, |
| 470 |
| 471 ucnv_MBCSGetStarters, |
| 472 ucnv_MBCSGetName, |
| 473 ucnv_MBCSWriteSub, |
| 474 NULL, |
| 475 ucnv_MBCSGetUnicodeSet, |
| 476 |
| 477 NULL, |
| 478 ucnv_DBCSFromUTF8 |
| 479 }; |
| 480 |
| 481 static const UConverterImpl _MBCSImpl={ |
| 482 UCNV_MBCS, |
| 483 |
| 484 ucnv_MBCSLoad, |
| 485 ucnv_MBCSUnload, |
| 486 |
| 487 ucnv_MBCSOpen, |
| 488 NULL, |
| 489 NULL, |
| 490 |
| 491 ucnv_MBCSToUnicodeWithOffsets, |
| 492 ucnv_MBCSToUnicodeWithOffsets, |
| 493 ucnv_MBCSFromUnicodeWithOffsets, |
| 494 ucnv_MBCSFromUnicodeWithOffsets, |
| 495 ucnv_MBCSGetNextUChar, |
| 496 |
| 497 ucnv_MBCSGetStarters, |
| 498 ucnv_MBCSGetName, |
| 499 ucnv_MBCSWriteSub, |
| 500 NULL, |
| 501 ucnv_MBCSGetUnicodeSet, |
| 502 NULL, |
| 503 NULL |
| 504 }; |
| 505 |
| 506 |
| 507 /* Static data is in tools/makeconv/ucnvstat.c for data-based |
| 508 * converters. Be sure to update it as well. |
| 509 */ |
| 510 |
| 511 const UConverterSharedData _MBCSData={ |
| 512 sizeof(UConverterSharedData), 1, |
| 513 NULL, NULL, NULL, FALSE, &_MBCSImpl, |
| 514 0, UCNV_MBCS_TABLE_INITIALIZER |
| 515 }; |
| 516 |
364 | 517 |
365 /* GB 18030 data ------------------------------------------------------------ */ | 518 /* GB 18030 data ------------------------------------------------------------ */ |
366 | 519 |
367 /* helper macros for linear values for GB 18030 four-byte sequences */ | 520 /* helper macros for linear values for GB 18030 four-byte sequences */ |
368 #define LINEAR_18030(a, b, c, d) ((((a)*10+(b))*126L+(c))*10L+(d)) | 521 #define LINEAR_18030(a, b, c, d) ((((a)*10+(b))*126L+(c))*10L+(d)) |
369 | 522 |
370 #define LINEAR_18030_BASE LINEAR_18030(0x81, 0x30, 0x81, 0x30) | 523 #define LINEAR_18030_BASE LINEAR_18030(0x81, 0x30, 0x81, 0x30) |
371 | 524 |
372 #define LINEAR(x) LINEAR_18030(x>>24, (x>>16)&0xff, (x>>8)&0xff, x&0xff) | 525 #define LINEAR(x) LINEAR_18030(x>>24, (x>>16)&0xff, (x>>8)&0xff, x&0xff) |
373 | 526 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 default: | 619 default: |
467 /* Should never happen. */ | 620 /* Should never happen. */ |
468 break; | 621 break; |
469 } | 622 } |
470 | 623 |
471 return SISOLength; | 624 return SISOLength; |
472 } | 625 } |
473 | 626 |
474 /* Miscellaneous ------------------------------------------------------------ */ | 627 /* Miscellaneous ------------------------------------------------------------ */ |
475 | 628 |
476 /** | |
477 * Callback from ucnv_MBCSEnumToUnicode(), takes 32 mappings from | |
478 * consecutive sequences of bytes, starting from the one encoded in value, | |
479 * to Unicode code points. (Multiple mappings to reduce per-function call overhe
ad.) | |
480 * Does not currently support m:n mappings or reverse fallbacks. | |
481 * This function will not be called for sequences of bytes with leading zeros. | |
482 * | |
483 * @param context an opaque pointer, as passed into ucnv_MBCSEnumToUnicode() | |
484 * @param value contains 1..4 bytes of the first byte sequence, right-aligned | |
485 * @param codePoints resulting Unicode code points, or negative if a byte sequen
ce does | |
486 * not map to anything | |
487 * @return TRUE to continue enumeration, FALSE to stop | |
488 */ | |
489 typedef UBool U_CALLCONV | |
490 UConverterEnumToUCallback(const void *context, uint32_t value, UChar32 codePoint
s[32]); | |
491 | |
492 /* similar to ucnv_MBCSGetNextUChar() but recursive */ | 629 /* similar to ucnv_MBCSGetNextUChar() but recursive */ |
493 static UBool | 630 static UBool |
494 enumToU(UConverterMBCSTable *mbcsTable, int8_t stateProps[], | 631 enumToU(UConverterMBCSTable *mbcsTable, int8_t stateProps[], |
495 int32_t state, uint32_t offset, | 632 int32_t state, uint32_t offset, |
496 uint32_t value, | 633 uint32_t value, |
497 UConverterEnumToUCallback *callback, const void *context, | 634 UConverterEnumToUCallback *callback, const void *context, |
498 UErrorCode *pErrorCode) { | 635 UErrorCode *pErrorCode) { |
499 UChar32 codePoints[32]; | 636 UChar32 codePoints[32]; |
500 const int32_t *row; | 637 const int32_t *row; |
501 const uint16_t *unicodeCodeUnits; | 638 const uint16_t *unicodeCodeUnits; |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 ) { | 1117 ) { |
981 return 0; /* an extension mapping handled the input */ | 1118 return 0; /* an extension mapping handled the input */ |
982 } | 1119 } |
983 | 1120 |
984 /* GB 18030 */ | 1121 /* GB 18030 */ |
985 if((cnv->options&_MBCS_OPTION_GB18030)!=0) { | 1122 if((cnv->options&_MBCS_OPTION_GB18030)!=0) { |
986 const uint32_t *range; | 1123 const uint32_t *range; |
987 int32_t i; | 1124 int32_t i; |
988 | 1125 |
989 range=gb18030Ranges[0]; | 1126 range=gb18030Ranges[0]; |
990 for(i=0; i<sizeof(gb18030Ranges)/sizeof(gb18030Ranges[0]); range+=4, ++i
) { | 1127 for(i=0; i<UPRV_LENGTHOF(gb18030Ranges); range+=4, ++i) { |
991 if(range[0]<=(uint32_t)cp && (uint32_t)cp<=range[1]) { | 1128 if(range[0]<=(uint32_t)cp && (uint32_t)cp<=range[1]) { |
992 /* found the Unicode code point, output the four-byte sequence f
or it */ | 1129 /* found the Unicode code point, output the four-byte sequence f
or it */ |
993 uint32_t linear; | 1130 uint32_t linear; |
994 char bytes[4]; | 1131 char bytes[4]; |
995 | 1132 |
996 /* get the linear value of the first GB 18030 code in this range
*/ | 1133 /* get the linear value of the first GB 18030 code in this range
*/ |
997 linear=range[2]-LINEAR_18030_BASE; | 1134 linear=range[2]-LINEAR_18030_BASE; |
998 | 1135 |
999 /* add the offset from the beginning of the range */ | 1136 /* add the offset from the beginning of the range */ |
1000 linear+=((uint32_t)cp-range[0]); | 1137 linear+=((uint32_t)cp-range[0]); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 } | 1184 } |
1048 | 1185 |
1049 /* GB 18030 */ | 1186 /* GB 18030 */ |
1050 if(length==4 && (cnv->options&_MBCS_OPTION_GB18030)!=0) { | 1187 if(length==4 && (cnv->options&_MBCS_OPTION_GB18030)!=0) { |
1051 const uint32_t *range; | 1188 const uint32_t *range; |
1052 uint32_t linear; | 1189 uint32_t linear; |
1053 int32_t i; | 1190 int32_t i; |
1054 | 1191 |
1055 linear=LINEAR_18030(cnv->toUBytes[0], cnv->toUBytes[1], cnv->toUBytes[2]
, cnv->toUBytes[3]); | 1192 linear=LINEAR_18030(cnv->toUBytes[0], cnv->toUBytes[1], cnv->toUBytes[2]
, cnv->toUBytes[3]); |
1056 range=gb18030Ranges[0]; | 1193 range=gb18030Ranges[0]; |
1057 for(i=0; i<sizeof(gb18030Ranges)/sizeof(gb18030Ranges[0]); range+=4, ++i
) { | 1194 for(i=0; i<UPRV_LENGTHOF(gb18030Ranges); range+=4, ++i) { |
1058 if(range[2]<=linear && linear<=range[3]) { | 1195 if(range[2]<=linear && linear<=range[3]) { |
1059 /* found the sequence, output the Unicode code point for it */ | 1196 /* found the sequence, output the Unicode code point for it */ |
1060 *pErrorCode=U_ZERO_ERROR; | 1197 *pErrorCode=U_ZERO_ERROR; |
1061 | 1198 |
1062 /* add the linear difference between the input and start sequenc
es to the start code point */ | 1199 /* add the linear difference between the input and start sequenc
es to the start code point */ |
1063 linear=range[0]+(linear-range[2]); | 1200 linear=range[0]+(linear-range[2]); |
1064 | 1201 |
1065 /* output this code point */ | 1202 /* output this code point */ |
1066 ucnv_toUWriteCodePoint(cnv, linear, target, targetLimit, offsets
, sourceIndex, pErrorCode); | 1203 ucnv_toUWriteCodePoint(cnv, linear, target, targetLimit, offsets
, sourceIndex, pErrorCode); |
1067 | 1204 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 stage2=(uint32_t *)stage1; | 1504 stage2=(uint32_t *)stage1; |
1368 | 1505 |
1369 /* reconstitute the initial part of stage 2 from the mbcsIndex */ | 1506 /* reconstitute the initial part of stage 2 from the mbcsIndex */ |
1370 { | 1507 { |
1371 int32_t stageUTF8Length=((int32_t)mbcsTable->maxFastUChar+1)>>6; | 1508 int32_t stageUTF8Length=((int32_t)mbcsTable->maxFastUChar+1)>>6; |
1372 int32_t stageUTF8Index=0; | 1509 int32_t stageUTF8Index=0; |
1373 int32_t st1, st2, st3, i; | 1510 int32_t st1, st2, st3, i; |
1374 | 1511 |
1375 for(st1=0; stageUTF8Index<stageUTF8Length; ++st1) { | 1512 for(st1=0; stageUTF8Index<stageUTF8Length; ++st1) { |
1376 st2=stage1[st1]; | 1513 st2=stage1[st1]; |
1377 if(st2!=stage1Length/2) { | 1514 if(st2!=(int32_t)stage1Length/2) { |
1378 /* each stage 2 block has 64 entries corresponding to 16 entries
in the mbcsIndex */ | 1515 /* each stage 2 block has 64 entries corresponding to 16 entries
in the mbcsIndex */ |
1379 for(i=0; i<16; ++i) { | 1516 for(i=0; i<16; ++i) { |
1380 st3=mbcsTable->mbcsIndex[stageUTF8Index++]; | 1517 st3=mbcsTable->mbcsIndex[stageUTF8Index++]; |
1381 if(st3!=0) { | 1518 if(st3!=0) { |
1382 /* an stage 2 entry's index is per stage 3 16-block, not
per stage 3 entry */ | 1519 /* an stage 2 entry's index is per stage 3 16-block, not
per stage 3 entry */ |
1383 st3>>=4; | 1520 st3>>=4; |
1384 /* | 1521 /* |
1385 * 4 stage 2 entries point to 4 consecutive stage 3 16-b
locks which are | 1522 * 4 stage 2 entries point to 4 consecutive stage 3 16-b
locks which are |
1386 * allocated together as a single 64-block for access fr
om the mbcsIndex | 1523 * allocated together as a single 64-block for access fr
om the mbcsIndex |
1387 */ | 1524 */ |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 return; | 1573 return; |
1437 } | 1574 } |
1438 | 1575 |
1439 /* extension data, header version 4.2 and higher */ | 1576 /* extension data, header version 4.2 and higher */ |
1440 offset=header->flags>>8; | 1577 offset=header->flags>>8; |
1441 if(offset!=0) { | 1578 if(offset!=0) { |
1442 mbcsTable->extIndexes=(const int32_t *)(raw+offset); | 1579 mbcsTable->extIndexes=(const int32_t *)(raw+offset); |
1443 } | 1580 } |
1444 | 1581 |
1445 if(mbcsTable->outputType==MBCS_OUTPUT_EXT_ONLY) { | 1582 if(mbcsTable->outputType==MBCS_OUTPUT_EXT_ONLY) { |
1446 UConverterLoadArgs args={ 0 }; | 1583 UConverterLoadArgs args=UCNV_LOAD_ARGS_INITIALIZER; |
1447 UConverterSharedData *baseSharedData; | 1584 UConverterSharedData *baseSharedData; |
1448 const int32_t *extIndexes; | 1585 const int32_t *extIndexes; |
1449 const char *baseName; | 1586 const char *baseName; |
1450 | 1587 |
1451 /* extension-only file, load the base table and set values appropriately
*/ | 1588 /* extension-only file, load the base table and set values appropriately
*/ |
1452 if((extIndexes=mbcsTable->extIndexes)==NULL) { | 1589 if((extIndexes=mbcsTable->extIndexes)==NULL) { |
1453 /* extension-only file without extension */ | 1590 /* extension-only file without extension */ |
1454 *pErrorCode=U_INVALID_TABLE_FORMAT; | 1591 *pErrorCode=U_INVALID_TABLE_FORMAT; |
1455 return; | 1592 return; |
1456 } | 1593 } |
(...skipping 4015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5472 /* write back the updated pointers */ | 5609 /* write back the updated pointers */ |
5473 pToUArgs->source=(char *)source; | 5610 pToUArgs->source=(char *)source; |
5474 pFromUArgs->target=(char *)target; | 5611 pFromUArgs->target=(char *)target; |
5475 } | 5612 } |
5476 | 5613 |
5477 /* miscellaneous ------------------------------------------------------------ */ | 5614 /* miscellaneous ------------------------------------------------------------ */ |
5478 | 5615 |
5479 static void | 5616 static void |
5480 ucnv_MBCSGetStarters(const UConverter* cnv, | 5617 ucnv_MBCSGetStarters(const UConverter* cnv, |
5481 UBool starters[256], | 5618 UBool starters[256], |
5482 UErrorCode *pErrorCode) { | 5619 UErrorCode *) { |
5483 const int32_t *state0; | 5620 const int32_t *state0; |
5484 int i; | 5621 int i; |
5485 | 5622 |
5486 state0=cnv->sharedData->mbcs.stateTable[cnv->sharedData->mbcs.dbcsOnlyState]
; | 5623 state0=cnv->sharedData->mbcs.stateTable[cnv->sharedData->mbcs.dbcsOnlyState]
; |
5487 for(i=0; i<256; ++i) { | 5624 for(i=0; i<256; ++i) { |
5488 /* all bytes that cause a state transition from state 0 are lead bytes *
/ | 5625 /* all bytes that cause a state transition from state 0 are lead bytes *
/ |
5489 starters[i]= (UBool)MBCS_ENTRY_IS_TRANSITION(state0[i]); | 5626 starters[i]= (UBool)MBCS_ENTRY_IS_TRANSITION(state0[i]); |
5490 } | 5627 } |
5491 } | 5628 } |
5492 | 5629 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5565 if(converter->sharedData->mbcs.countStates==1) { | 5702 if(converter->sharedData->mbcs.countStates==1) { |
5566 return (UConverterType)UCNV_SBCS; | 5703 return (UConverterType)UCNV_SBCS; |
5567 } else if((converter->sharedData->mbcs.outputType&0xff)==MBCS_OUTPUT_2_SISO)
{ | 5704 } else if((converter->sharedData->mbcs.outputType&0xff)==MBCS_OUTPUT_2_SISO)
{ |
5568 return (UConverterType)UCNV_EBCDIC_STATEFUL; | 5705 return (UConverterType)UCNV_EBCDIC_STATEFUL; |
5569 } else if(converter->sharedData->staticData->minBytesPerChar==2 && converter
->sharedData->staticData->maxBytesPerChar==2) { | 5706 } else if(converter->sharedData->staticData->minBytesPerChar==2 && converter
->sharedData->staticData->maxBytesPerChar==2) { |
5570 return (UConverterType)UCNV_DBCS; | 5707 return (UConverterType)UCNV_DBCS; |
5571 } | 5708 } |
5572 return (UConverterType)UCNV_MBCS; | 5709 return (UConverterType)UCNV_MBCS; |
5573 } | 5710 } |
5574 | 5711 |
5575 static const UConverterImpl _SBCSUTF8Impl={ | |
5576 UCNV_MBCS, | |
5577 | |
5578 ucnv_MBCSLoad, | |
5579 ucnv_MBCSUnload, | |
5580 | |
5581 ucnv_MBCSOpen, | |
5582 NULL, | |
5583 NULL, | |
5584 | |
5585 ucnv_MBCSToUnicodeWithOffsets, | |
5586 ucnv_MBCSToUnicodeWithOffsets, | |
5587 ucnv_MBCSFromUnicodeWithOffsets, | |
5588 ucnv_MBCSFromUnicodeWithOffsets, | |
5589 ucnv_MBCSGetNextUChar, | |
5590 | |
5591 ucnv_MBCSGetStarters, | |
5592 ucnv_MBCSGetName, | |
5593 ucnv_MBCSWriteSub, | |
5594 NULL, | |
5595 ucnv_MBCSGetUnicodeSet, | |
5596 | |
5597 NULL, | |
5598 ucnv_SBCSFromUTF8 | |
5599 }; | |
5600 | |
5601 static const UConverterImpl _DBCSUTF8Impl={ | |
5602 UCNV_MBCS, | |
5603 | |
5604 ucnv_MBCSLoad, | |
5605 ucnv_MBCSUnload, | |
5606 | |
5607 ucnv_MBCSOpen, | |
5608 NULL, | |
5609 NULL, | |
5610 | |
5611 ucnv_MBCSToUnicodeWithOffsets, | |
5612 ucnv_MBCSToUnicodeWithOffsets, | |
5613 ucnv_MBCSFromUnicodeWithOffsets, | |
5614 ucnv_MBCSFromUnicodeWithOffsets, | |
5615 ucnv_MBCSGetNextUChar, | |
5616 | |
5617 ucnv_MBCSGetStarters, | |
5618 ucnv_MBCSGetName, | |
5619 ucnv_MBCSWriteSub, | |
5620 NULL, | |
5621 ucnv_MBCSGetUnicodeSet, | |
5622 | |
5623 NULL, | |
5624 ucnv_DBCSFromUTF8 | |
5625 }; | |
5626 | |
5627 static const UConverterImpl _MBCSImpl={ | |
5628 UCNV_MBCS, | |
5629 | |
5630 ucnv_MBCSLoad, | |
5631 ucnv_MBCSUnload, | |
5632 | |
5633 ucnv_MBCSOpen, | |
5634 NULL, | |
5635 NULL, | |
5636 | |
5637 ucnv_MBCSToUnicodeWithOffsets, | |
5638 ucnv_MBCSToUnicodeWithOffsets, | |
5639 ucnv_MBCSFromUnicodeWithOffsets, | |
5640 ucnv_MBCSFromUnicodeWithOffsets, | |
5641 ucnv_MBCSGetNextUChar, | |
5642 | |
5643 ucnv_MBCSGetStarters, | |
5644 ucnv_MBCSGetName, | |
5645 ucnv_MBCSWriteSub, | |
5646 NULL, | |
5647 ucnv_MBCSGetUnicodeSet | |
5648 }; | |
5649 | |
5650 | |
5651 /* Static data is in tools/makeconv/ucnvstat.c for data-based | |
5652 * converters. Be sure to update it as well. | |
5653 */ | |
5654 | |
5655 const UConverterSharedData _MBCSData={ | |
5656 sizeof(UConverterSharedData), 1, | |
5657 NULL, NULL, NULL, FALSE, &_MBCSImpl, | |
5658 0 | |
5659 }; | |
5660 | |
5661 #endif /* #if !UCONFIG_NO_LEGACY_CONVERSION */ | 5712 #endif /* #if !UCONFIG_NO_LEGACY_CONVERSION */ |
OLD | NEW |