mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-3857 Return a CCSID for gb18030
X-SVN-Rev: 16043
This commit is contained in:
parent
1406c1d12b
commit
a8c47516eb
2 changed files with 17 additions and 6 deletions
|
@ -592,14 +592,24 @@ ucnv_getName (const UConverter * converter, UErrorCode * err)
|
|||
return converter->sharedData->staticData->name;
|
||||
}
|
||||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
ucnv_getCCSID (const UConverter * converter,
|
||||
UErrorCode * err)
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
ucnv_getCCSID(const UConverter * converter,
|
||||
UErrorCode * err)
|
||||
{
|
||||
int32_t ccsid;
|
||||
if (U_FAILURE (*err))
|
||||
return -1;
|
||||
|
||||
return converter->sharedData->staticData->codepage;
|
||||
ccsid = converter->sharedData->staticData->codepage;
|
||||
if (ccsid == 0) {
|
||||
/* Rare case. This is for cases like gb18030, which doesn't have an IBM cannonical */
|
||||
const char *standardName = ucnv_getStandardName(ucnv_getName(converter, err), "IBM", err);
|
||||
if (U_SUCCESS(*err) && standardName) {
|
||||
const char *ccsidStr = uprv_strchr(standardName, '-') + 1;
|
||||
ccsid = (int32_t)atof(ccsidStr);
|
||||
}
|
||||
}
|
||||
return ccsid;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1866,7 +1866,7 @@ static void TestConvertSafeClone()
|
|||
static void TestCCSID() {
|
||||
UConverter *cnv;
|
||||
UErrorCode errorCode;
|
||||
int32_t ccsids[]={ 37, 850, 943, 949, 950, 1047, 1252, 33722 };
|
||||
int32_t ccsids[]={ 37, 850, 943, 949, 950, 1047, 1252, 1392, 33722 };
|
||||
int32_t i, ccsid;
|
||||
|
||||
for(i=0; i<(int32_t)(sizeof(ccsids)/sizeof(int32_t)); ++i) {
|
||||
|
@ -1883,7 +1883,8 @@ static void TestCCSID() {
|
|||
log_err("error: ucnv_getCCSID(ucnv_openCCSID(%ld))=%ld\n", ccsid, ucnv_getCCSID(cnv, &errorCode));
|
||||
}
|
||||
|
||||
if(UCNV_IBM!=ucnv_getPlatform(cnv, &errorCode)) {
|
||||
/* skip gb18030(ccsid 1392) */
|
||||
if(ccsid != 1392 && UCNV_IBM!=ucnv_getPlatform(cnv, &errorCode)) {
|
||||
log_err("error: ucnv_getPlatform(ucnv_openCCSID(%ld))=%ld!=UCNV_IBM\n", ccsid, ucnv_getPlatform(cnv, &errorCode));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue