ICU-5518 fix swapping and preflighting of UTF-8-friendly MBCS .cnv files without extension tables
X-SVN-Rev: 21013
This commit is contained in:
parent
c24de1764d
commit
e674e4f0f0
@ -1237,6 +1237,8 @@ ucnv_swap(const UDataSwapper *ds,
|
||||
_MBCSHeader mbcsHeader;
|
||||
uint8_t outputType;
|
||||
|
||||
int32_t maxFastUChar, mbcsIndexLength;
|
||||
|
||||
const int32_t *inExtIndexes;
|
||||
int32_t extOffset;
|
||||
|
||||
@ -1361,8 +1363,24 @@ ucnv_swap(const UDataSwapper *ds,
|
||||
}
|
||||
|
||||
/* calculate the length of the MBCS data */
|
||||
|
||||
/*
|
||||
* utf8Friendly MBCS files (mbcsHeader.version 4.3)
|
||||
* contain an additional mbcsIndex table:
|
||||
* uint16_t[(maxFastUChar+1)>>6];
|
||||
* where maxFastUChar=((mbcsHeader.version[2]<<8)|0xff).
|
||||
*/
|
||||
maxFastUChar=0;
|
||||
mbcsIndexLength=0;
|
||||
if( outputType!=MBCS_OUTPUT_EXT_ONLY && outputType!=MBCS_OUTPUT_1 &&
|
||||
mbcsHeader.version[1]>=3 && (maxFastUChar=mbcsHeader.version[2])!=0
|
||||
) {
|
||||
maxFastUChar=(maxFastUChar<<8)|0xff;
|
||||
mbcsIndexLength=((maxFastUChar+1)>>6)*2; /* number of bytes */
|
||||
}
|
||||
|
||||
if(extOffset==0) {
|
||||
size=(int32_t)(mbcsHeader.offsetFromUBytes+mbcsHeader.fromUBytesLength);
|
||||
size=(int32_t)(mbcsHeader.offsetFromUBytes+mbcsHeader.fromUBytesLength+mbcsIndexLength);
|
||||
|
||||
/* avoid compiler warnings - not otherwise necessary, and the value does not matter */
|
||||
inExtIndexes=NULL;
|
||||
@ -1433,7 +1451,6 @@ ucnv_swap(const UDataSwapper *ds,
|
||||
outBytes+offset, pErrorCode);
|
||||
} else {
|
||||
/* otherwise: swap the stage tables separately */
|
||||
int32_t maxFastUChar;
|
||||
|
||||
/* stage 1 table: uint16_t[0x440 or 0x40] */
|
||||
if(inStaticData->unicodeMask&UCNV_HAS_SUPPLEMENTARY) {
|
||||
@ -1469,16 +1486,9 @@ ucnv_swap(const UDataSwapper *ds,
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* utf8Friendly MBCS files (mbcsHeader.version 4.3)
|
||||
* contain an additional mbcsIndex table:
|
||||
* uint16_t[(maxFastUChar+1)>>6];
|
||||
* where maxFastUChar=((mbcsHeader.version[2]<<8)|0xff).
|
||||
*/
|
||||
if(mbcsHeader.version[1]>=3 && (maxFastUChar=mbcsHeader.version[2])!=0) {
|
||||
maxFastUChar=(maxFastUChar<<8)|0xff;
|
||||
if(mbcsIndexLength!=0) {
|
||||
offset+=count;
|
||||
count=((maxFastUChar+1)>>6)*2;
|
||||
count=mbcsIndexLength;
|
||||
ds->swapArray16(ds, inBytes+offset, (int32_t)count,
|
||||
outBytes+offset, pErrorCode);
|
||||
}
|
||||
|
@ -1277,6 +1277,11 @@ static const struct {
|
||||
{"gb18030", "cnv", ucnv_swap},
|
||||
/* MBCS conversion table file with extension */
|
||||
{"*test4x", "cnv", ucnv_swap},
|
||||
/*
|
||||
* MBCS conversion table file without extension,
|
||||
* to test swapping and preflighting of UTF-8-friendly mbcsIndex[].
|
||||
*/
|
||||
{"jisx-208", "cnv", ucnv_swap},
|
||||
#endif
|
||||
|
||||
#if !UCONFIG_NO_CONVERSION
|
||||
|
Loading…
Reference in New Issue
Block a user