mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 17:24:01 +00:00
ICU-484 replace SBCS by MBCS
X-SVN-Rev: 3297
This commit is contained in:
parent
bbc83cc691
commit
d8b3114228
15 changed files with 84 additions and 35 deletions
|
@ -21,8 +21,6 @@
|
|||
#include "umutex.h"
|
||||
#include "unicode/ures.h"
|
||||
#include "uhash.h"
|
||||
#include "ucmp16.h"
|
||||
#include "ucmp8.h"
|
||||
#include "ucnv_io.h"
|
||||
#include "unicode/ucnv_err.h"
|
||||
#include "ucnv_cnv.h"
|
||||
|
@ -1198,7 +1196,14 @@ int32_t ucnv_convert(const char *toConverterName,
|
|||
|
||||
UConverterType ucnv_getType(const UConverter* converter)
|
||||
{
|
||||
return (UConverterType)converter->sharedData->staticData->conversionType;
|
||||
int8_t type = converter->sharedData->staticData->conversionType;
|
||||
if(type == UCNV_MBCS) {
|
||||
/* SBCS is replaced by MBCS, but here we cheat a little */
|
||||
if(converter->sharedData->table->mbcs.countStates == 1) {
|
||||
return (UConverterType)UCNV_SBCS;
|
||||
}
|
||||
}
|
||||
return (UConverterType)type;
|
||||
}
|
||||
|
||||
void ucnv_getStarters(const UConverter* converter,
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "unicode/utypes.h"
|
||||
#include "cmemory.h"
|
||||
#include "ucmp16.h"
|
||||
#include "ucmp8.h"
|
||||
/* SBCS needed: #include "ucmp8.h" */
|
||||
#include "unicode/ucnv_err.h"
|
||||
#include "ucnv_bld.h"
|
||||
#include "unicode/ucnv.h"
|
||||
|
@ -1197,8 +1197,8 @@ U_CFUNC void UConverter_fromUnicode_ISO_2022_JP(UConverterFromUnicodeArgs* args,
|
|||
int32_t myTargetIndex = 0;
|
||||
CompactShortArray *myFromUnicodeDBCS = NULL;
|
||||
CompactShortArray *myFromUnicodeDBCSFallback = NULL;
|
||||
CompactByteArray *myFromUnicodeSBCS = NULL;
|
||||
CompactByteArray *myFromUnicodeSBCSFallback = NULL;
|
||||
/* SBCS was: CompactByteArray *myFromUnicodeSBCS = NULL; */
|
||||
/* SBCS was: CompactByteArray *myFromUnicodeSBCSFallback = NULL; */
|
||||
UChar32 targetUniChar = missingCharMarker;
|
||||
StateEnum currentState=ASCII;
|
||||
Cnv2022Type myType =ASCII1;
|
||||
|
@ -1309,6 +1309,13 @@ getTrail:
|
|||
switch (myType){
|
||||
|
||||
case SBCS:
|
||||
targetUniChar = (uint16_t)_MBCSSingleFromUChar32(myConverterData->fromUnicodeConverter->sharedData, mySourceChar, FALSE);
|
||||
/*
|
||||
* If mySourceChar is unassigned, then _MBCSSingleFromUChar32() returns -1
|
||||
* which becomes the same as missingCharMarker with the cast to uint16_t.
|
||||
*/
|
||||
#if 0
|
||||
/* SBCS was: */
|
||||
if( mySourceChar <0xffff) {
|
||||
myFromUnicodeSBCS = &myConverterData->fromUnicodeConverter->sharedData->table->sbcs.fromUnicode;
|
||||
myFromUnicodeSBCSFallback = &myConverterData->fromUnicodeConverter->sharedData->table->sbcs.fromUnicodeFallback;
|
||||
|
@ -1325,6 +1332,7 @@ getTrail:
|
|||
/* ucmp8_getU returns 0 for missing char so explicitly set it missingCharMarker*/
|
||||
targetUniChar=(UChar)((targetUniChar==0) ? (UChar) missingCharMarker : targetUniChar);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case DBCS:
|
||||
|
@ -1506,8 +1514,8 @@ U_CFUNC void UConverter_fromUnicode_ISO_2022_JP_OFFSETS_LOGIC(UConverterFromUnic
|
|||
int32_t myTargetIndex = 0;
|
||||
CompactShortArray *myFromUnicodeDBCS = NULL;
|
||||
CompactShortArray *myFromUnicodeDBCSFallback = NULL;
|
||||
CompactByteArray *myFromUnicodeSBCS = NULL;
|
||||
CompactByteArray *myFromUnicodeSBCSFallback = NULL;
|
||||
/* SBCS was: CompactByteArray *myFromUnicodeSBCS = NULL; */
|
||||
/* SBCS was: CompactByteArray *myFromUnicodeSBCSFallback = NULL; */
|
||||
UChar32 targetUniChar = missingCharMarker;
|
||||
StateEnum currentState=ASCII;
|
||||
Cnv2022Type myType=ASCII1;
|
||||
|
@ -1619,6 +1627,13 @@ getTrail:
|
|||
switch (myType){
|
||||
|
||||
case SBCS:
|
||||
targetUniChar = (uint16_t)_MBCSSingleFromUChar32(myConverterData->fromUnicodeConverter->sharedData, mySourceChar, FALSE);
|
||||
/*
|
||||
* If mySourceChar is unassigned, then _MBCSSingleFromUChar32() returns -1
|
||||
* which becomes the same as missingCharMarker with the cast to uint16_t.
|
||||
*/
|
||||
#if 0
|
||||
/* SBCS was: */
|
||||
if(mySourceChar < 0xffff){
|
||||
myFromUnicodeSBCS = &myConverterData->fromUnicodeConverter->sharedData->table->sbcs.fromUnicode;
|
||||
myFromUnicodeSBCSFallback = &myConverterData->fromUnicodeConverter->sharedData->table->sbcs.fromUnicodeFallback;
|
||||
|
@ -1636,6 +1651,7 @@ getTrail:
|
|||
/* ucmp8_getU returns 0 for missing char so explicitly set it missingCharMarker*/
|
||||
targetUniChar=(UChar)((targetUniChar==0) ? (UChar) missingCharMarker : targetUniChar);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case DBCS:
|
||||
|
@ -2048,6 +2064,9 @@ U_CFUNC void UConverter_toUnicode_ISO_2022_JP(UConverterToUnicodeArgs *args,
|
|||
break;
|
||||
case SBCS:
|
||||
if(args->converter->toUnicodeStatus == 0x00){
|
||||
targetUniChar = _MBCS_SINGLE_SIMPLE_GET_NEXT_BMP(myData->currentConverter->sharedData, mySourceChar);
|
||||
#if 0
|
||||
/* SBCS was: */
|
||||
myToUnicodeSBCS = myData->currentConverter->sharedData->table->sbcs.toUnicode;
|
||||
myToUnicodeFallbackSBCS = myData->currentConverter->sharedData->table->sbcs.toUnicodeFallback;
|
||||
targetUniChar = myToUnicodeSBCS[(unsigned char) mySourceChar];
|
||||
|
@ -2063,7 +2082,7 @@ U_CFUNC void UConverter_toUnicode_ISO_2022_JP(UConverterToUnicodeArgs *args,
|
|||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
}
|
||||
else{
|
||||
goto SAVE_STATE;
|
||||
|
@ -2285,6 +2304,9 @@ U_CFUNC void UConverter_toUnicode_ISO_2022_JP_OFFSETS_LOGIC(UConverterToUnicodeA
|
|||
break;
|
||||
case SBCS:
|
||||
if(args->converter->toUnicodeStatus == 0x00){
|
||||
targetUniChar = _MBCS_SINGLE_SIMPLE_GET_NEXT_BMP(myData->currentConverter->sharedData, mySourceChar);
|
||||
#if 0
|
||||
/* SBCS was: */
|
||||
myToUnicodeSBCS = myData->currentConverter->sharedData->table->sbcs.toUnicode;
|
||||
myToUnicodeFallbackSBCS = myData->currentConverter->sharedData->table->sbcs.toUnicodeFallback;
|
||||
targetUniChar = myToUnicodeSBCS[(unsigned char) mySourceChar];
|
||||
|
@ -2300,6 +2322,7 @@ U_CFUNC void UConverter_toUnicode_ISO_2022_JP_OFFSETS_LOGIC(UConverterToUnicodeA
|
|||
}
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
else{
|
||||
goto SAVE_STATE;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "ucnv_io.h"
|
||||
#include "uhash.h"
|
||||
#include "ucmp16.h"
|
||||
#include "ucmp8.h"
|
||||
#include "ucnv_bld.h"
|
||||
#include "unicode/ucnv_err.h"
|
||||
#include "ucnv_cnv.h"
|
||||
|
|
|
@ -22,9 +22,11 @@
|
|||
#include "unicode/ucnv_err.h"
|
||||
#include "ucnv_bld.h"
|
||||
#include "ucnvmbcs.h"
|
||||
#include "ucmp8.h"
|
||||
/* SBCS needed: #include "ucmp8.h" */
|
||||
#include "ucmp16.h"
|
||||
|
||||
#if 0
|
||||
/* SBCS was: */
|
||||
/*Table Node Definitions */
|
||||
typedef struct
|
||||
{
|
||||
|
@ -34,6 +36,7 @@ typedef struct
|
|||
CompactByteArray fromUnicodeFallback;
|
||||
}
|
||||
UConverterSBCSTable;
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -46,7 +49,7 @@ UConverterDBCSTable;
|
|||
|
||||
union UConverterTable
|
||||
{
|
||||
UConverterSBCSTable sbcs;
|
||||
/* UConverterSBCSTable sbcs; */
|
||||
UConverterDBCSTable dbcs;
|
||||
UConverterMBCSTable mbcs;
|
||||
};
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
* 06/29/2000 helena Major rewrite of the callback APIs.
|
||||
*/
|
||||
|
||||
#include "ucmp8.h"
|
||||
#include "ucmp16.h"
|
||||
#include "unicode/ucnv_err.h"
|
||||
#include "unicode/ucnv_cb.h"
|
||||
#include "ucnv_cnv.h"
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "unicode/utypes.h"
|
||||
#include "cmemory.h"
|
||||
#include "ucmp16.h"
|
||||
#include "ucmp8.h"
|
||||
/* SBCS needed: #include "ucmp8.h" */
|
||||
#include "unicode/ucnv_err.h"
|
||||
#include "ucnv_bld.h"
|
||||
#include "unicode/ucnv.h"
|
||||
|
@ -1081,7 +1081,8 @@ _LMBCSGetNextUCharWorker(UConverterToUnicodeArgs* args,
|
|||
|
||||
if (CurByte >= ULMBCS_C1START)
|
||||
{
|
||||
uniChar = cnv->sharedData->table->sbcs.toUnicode[CurByte];
|
||||
uniChar = _MBCS_SINGLE_SIMPLE_GET_NEXT_BMP(cnv->sharedData, CurByte);
|
||||
/* SBCS was: uniChar = cnv->sharedData->table->sbcs.toUnicode[CurByte]; */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1130,7 +1131,8 @@ _LMBCSGetNextUCharWorker(UConverterToUnicodeArgs* args,
|
|||
}
|
||||
else /* single byte conversion */
|
||||
{
|
||||
uniChar = cnv->sharedData->table->sbcs.toUnicode[CurByte];
|
||||
uniChar = _MBCS_SINGLE_SIMPLE_GET_NEXT_BMP(cnv->sharedData, CurByte);
|
||||
/* SBCS was: uniChar = cnv->sharedData->table->sbcs.toUnicode[CurByte]; */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
|
||||
#include "cmemory.h"
|
||||
#include "unicode/utypes.h"
|
||||
#include "ucmp16.h"
|
||||
#include "ucmp8.h"
|
||||
#include "unicode/ucnv_err.h"
|
||||
#include "ucnv_bld.h"
|
||||
#include "unicode/ucnv.h"
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "unicode/utypes.h"
|
||||
#include "cmemory.h"
|
||||
#include "ucmp16.h"
|
||||
#include "ucmp8.h"
|
||||
#include "unicode/ucnv_err.h"
|
||||
#include "ucnv_bld.h"
|
||||
#include "unicode/ucnv.h"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "unicode/utypes.h"
|
||||
#include "cmemory.h"
|
||||
#include "ucmp16.h"
|
||||
#include "ucmp8.h"
|
||||
#include "unicode/ucnv_err.h"
|
||||
#include "ucnv_bld.h"
|
||||
#include "unicode/ucnv.h"
|
||||
|
|
|
@ -158,7 +158,7 @@ _MBCSSingleSimpleGetNextUChar(UConverterSharedData *sharedData,
|
|||
* returns fallback values.
|
||||
*/
|
||||
#define _MBCS_SINGLE_SIMPLE_GET_NEXT_BMP(sharedData, b) \
|
||||
(UChar)(((sharedData)->table->mbcs.stateTable[0][b])>>7)
|
||||
(UChar)(((sharedData)->table->mbcs.stateTable[0][(uint8_t)(b)])>>7)
|
||||
|
||||
/**
|
||||
* This is an internal function that allows other converter implementations
|
||||
|
|
|
@ -21,12 +21,15 @@
|
|||
#include "unicode/utypes.h"
|
||||
#include "cmemory.h"
|
||||
#include "ucmp16.h"
|
||||
#include "ucmp8.h"
|
||||
/* SBCS needed: #include "ucmp8.h" */
|
||||
#include "unicode/ucnv_err.h"
|
||||
#include "ucnv_bld.h"
|
||||
#include "unicode/ucnv.h"
|
||||
#include "ucnv_cnv.h"
|
||||
|
||||
#if 0
|
||||
/* SBCS replaced by MBCS 2000dec20 */
|
||||
|
||||
/* SBCS --------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
|
@ -358,14 +361,15 @@ static const UConverterImpl _SBCSImpl={
|
|||
NULL
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/* Static data is in tools/makeconv/ucnvstat.c for data-based
|
||||
* converters. Be sure to update it as well.
|
||||
*/
|
||||
|
||||
const UConverterSharedData _SBCSData={
|
||||
sizeof(UConverterSharedData), 1,
|
||||
NULL, NULL, NULL, FALSE, &_SBCSImpl,
|
||||
sizeof(UConverterSharedData), 0 /* ### 1 to be operational */,
|
||||
NULL, NULL, NULL, FALSE, NULL /* ### &_SBCSImpl */,
|
||||
0
|
||||
};
|
||||
|
||||
|
|
|
@ -560,8 +560,10 @@ void readHeaderFromFile(UConverterSharedData* mySharedData,
|
|||
if ( myConverter->subCharLen == 0 )
|
||||
{
|
||||
myConverter->subCharLen = prototype->subCharLen;
|
||||
uprv_memcpy(myConverter->subChar, prototype->subChar,
|
||||
prototype->subCharLen);
|
||||
if(prototype->subCharLen>0) {
|
||||
uprv_memcpy(myConverter->subChar, prototype->subChar,
|
||||
prototype->subCharLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -826,12 +828,23 @@ UConverterSharedData* createConverterFromTableFile(const char* converterName, UE
|
|||
{
|
||||
case UCNV_SBCS:
|
||||
{
|
||||
mySharedData->table = (UConverterTable *)SBCSOpen();
|
||||
/* SBCS: use MBCS data structure with a default state table */
|
||||
myStaticData->conversionType = UCNV_MBCS;
|
||||
mySharedData->table = (UConverterTable *)MBCSOpen(mySharedData->staticData->maxBytesPerChar);
|
||||
if(mySharedData->table != NULL) {
|
||||
if(!MBCSAddState((NewConverter *)mySharedData->table, "0-ff")) {
|
||||
*err = U_INVALID_TABLE_FORMAT;
|
||||
((NewConverter *)mySharedData->table)->close((NewConverter *)mySharedData->table);
|
||||
mySharedData->table=NULL;
|
||||
}
|
||||
} else {
|
||||
*err = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case UCNV_MBCS:
|
||||
{
|
||||
/* MBCSOpen() was called by */
|
||||
/* MBCSOpen() was called by readHeaderFromFile() */
|
||||
break;
|
||||
}
|
||||
case UCNV_EBCDIC_STATEFUL:
|
||||
|
|
|
@ -55,8 +55,11 @@ struct NewConverter {
|
|||
};
|
||||
|
||||
/* object constructors */
|
||||
#if 0
|
||||
/* SBCS replaced by MBCS 2000dec20 */
|
||||
U_CFUNC NewConverter *
|
||||
SBCSOpen(void);
|
||||
#endif
|
||||
|
||||
U_CFUNC NewConverter *
|
||||
DBCSOpen(void);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "unicode/utypes.h"
|
||||
#include "cstring.h"
|
||||
#include "cmemory.h"
|
||||
#include "ucmp8.h"
|
||||
/* SBCS needed: #include "ucmp8.h" */
|
||||
#include "ucmp16.h"
|
||||
#include "ucnv_bld.h"
|
||||
#include "ucnv_cnv.h"
|
||||
|
@ -37,6 +37,9 @@
|
|||
#include "ucmpwrit.h"
|
||||
#include "makeconv.h"
|
||||
|
||||
#if 0
|
||||
/* SBCS replaced by MBCS 2000dec20 */
|
||||
|
||||
/* SBCS --------------------------------------------------------------------- */
|
||||
|
||||
typedef struct SBCSData {
|
||||
|
@ -229,6 +232,7 @@ SBCSWrite(NewConverter *cnvData, const UConverterStaticData *staticData, UNewDat
|
|||
}
|
||||
return size;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* DBCS and EBCDIC_STATEFUL ------------------------------------------------- */
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ static const UConverterStaticData _SBCSStaticData={
|
|||
sizeof(UConverterStaticData),
|
||||
"SBCS",
|
||||
0, UCNV_IBM, UCNV_SBCS, 1, 1,
|
||||
{ 0, 0, 0, 0 }, 1, FALSE, FALSE,
|
||||
{ 0x1a, 0, 0, 0 }, 1, FALSE, FALSE,
|
||||
0,
|
||||
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } /* reserved */
|
||||
};
|
||||
|
@ -30,7 +30,7 @@ static const UConverterStaticData _DBCSStaticData={
|
|||
sizeof(UConverterStaticData),
|
||||
"DBCS",
|
||||
0, UCNV_IBM, UCNV_DBCS, 2, 2,
|
||||
{ 0, 0, 0, 0 },1, FALSE, FALSE, /* subchar */
|
||||
{ 0, 0, 0, 0 },0, FALSE, FALSE, /* subchar */
|
||||
0,
|
||||
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } /* reserved */
|
||||
};
|
||||
|
@ -39,7 +39,7 @@ static const UConverterStaticData _MBCSStaticData={
|
|||
sizeof(UConverterStaticData),
|
||||
"MBCS",
|
||||
0, UCNV_IBM, UCNV_MBCS, 1, 1,
|
||||
{ 0, 0, 0, 0 }, 1, FALSE, FALSE,
|
||||
{ 0x1a, 0, 0, 0 }, 1, FALSE, FALSE,
|
||||
0,
|
||||
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } /* reserved */
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ static const UConverterStaticData _EBCDICStatefulStaticData={
|
|||
sizeof(UConverterStaticData),
|
||||
"EBCDICStateful",
|
||||
0, UCNV_IBM, UCNV_EBCDIC_STATEFUL, 1, 1,
|
||||
{ 0, 0, 0, 0 },1, FALSE, FALSE,
|
||||
{ 0, 0, 0, 0 },0, FALSE, FALSE,
|
||||
0,
|
||||
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } /* reserved */
|
||||
};
|
||||
|
@ -60,4 +60,3 @@ const UConverterStaticData *ucnv_converterStaticData[UCNV_NUMBER_OF_SUPPORTED_CO
|
|||
NULL/*ISO2022*/,
|
||||
/* LMBCS */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue