| Index: Source/wtf/text/TextCodecICU.cpp
|
| diff --git a/Source/wtf/text/TextCodecICU.cpp b/Source/wtf/text/TextCodecICU.cpp
|
| index 15beef74dc906cd436f93a86feb17a124a202858..2c3fb854c60730c85c2e4b1b9723b7b09074f9bd 100644
|
| --- a/Source/wtf/text/TextCodecICU.cpp
|
| +++ b/Source/wtf/text/TextCodecICU.cpp
|
| @@ -71,16 +71,20 @@ void TextCodecICU::registerEncodingNames(EncodingNameRegistrar registrar)
|
| for (int32_t i = 0; i < numEncodings; ++i) {
|
| const char* name = ucnv_getAvailableName(i);
|
| UErrorCode error = U_ZERO_ERROR;
|
| - // Try MIME before trying IANA to pick up commonly used names like
|
| - // 'EUC-JP' instead of horrendously long names like
|
| - // 'Extended_UNIX_Code_Packed_Format_for_Japanese'.
|
| - const char* standardName = ucnv_getStandardName(name, "MIME", &error);
|
| - if (!U_SUCCESS(error) || !standardName) {
|
| +#if !defined(USING_SYSTEM_ICU)
|
| + const char* primaryStandard = "HTML";
|
| + const char* secondaryStandard = "MIME";
|
| +#else
|
| + const char* primaryStandard = "MIME";
|
| + const char* secondaryStandard = "IANA";
|
| +#endif
|
| + const char* standardName = ucnv_getStandardName(name, primaryStandard, &error);
|
| + if (U_FAILURE(error) || !standardName) {
|
| error = U_ZERO_ERROR;
|
| // Try IANA to pick up 'windows-12xx' and other names
|
| // which are not preferred MIME names but are widely used.
|
| - standardName = ucnv_getStandardName(name, "IANA", &error);
|
| - if (!U_SUCCESS(error) || !standardName)
|
| + standardName = ucnv_getStandardName(name, secondaryStandard, &error);
|
| + if (U_FAILURE(error) || !standardName)
|
| continue;
|
| }
|
|
|
| @@ -90,6 +94,7 @@ void TextCodecICU::registerEncodingNames(EncodingNameRegistrar registrar)
|
| // 1. Treat GB2312 encoding as GBK (its more modern superset), to match other browsers.
|
| // 2. On the Web, GB2312 is encoded as EUC-CN or HZ, while ICU provides a native encoding
|
| // for encoding GB_2312-80 and several others. So, we need to override this behavior, too.
|
| +#if defined(USING_SYSTEM_ICU)
|
| if (!strcmp(standardName, "GB2312") || !strcmp(standardName, "GB_2312-80"))
|
| standardName = "GBK";
|
| // Similarly, EUC-KR encodings all map to an extended version, but
|
| @@ -101,6 +106,7 @@ void TextCodecICU::registerEncodingNames(EncodingNameRegistrar registrar)
|
| standardName = "windows-1254";
|
| else if (!strcmp(standardName, "TIS-620"))
|
| standardName = "windows-874";
|
| +#endif
|
|
|
| registrar(standardName, standardName);
|
|
|
| @@ -116,6 +122,12 @@ void TextCodecICU::registerEncodingNames(EncodingNameRegistrar registrar)
|
| }
|
| }
|
|
|
| + // These two entries have to be added here because ICU's converter table
|
| + // cannot have both ISO-8859-8-I and ISO-8859-8.
|
| + registrar("csISO88598I", "ISO-8859-8-I");
|
| + registrar("logical", "ISO-8859-8-I");
|
| +
|
| +#if defined(USING_SYSTEM_ICU)
|
| // Additional alias for MacCyrillic not present in ICU.
|
| registrar("maccyrillic", "x-mac-cyrillic");
|
|
|
| @@ -131,9 +143,7 @@ void TextCodecICU::registerEncodingNames(EncodingNameRegistrar registrar)
|
| registrar("csgb231280", "GBK");
|
| registrar("x-euc-cn", "GBK");
|
| registrar("x-gbk", "GBK");
|
| - registrar("csISO88598I", "ISO-8859-8-I");
|
| registrar("koi", "KOI8-R");
|
| - registrar("logical", "ISO-8859-8-I");
|
| registrar("visual", "ISO-8859-8");
|
| registrar("winarabic", "windows-1256");
|
| registrar("winbaltic", "windows-1257");
|
| @@ -176,8 +186,6 @@ void TextCodecICU::registerEncodingNames(EncodingNameRegistrar registrar)
|
| // and Firefox (as of Oct 2014), but not in the upstream ICU.
|
| // Three entries for windows-1252 need not be listed here because
|
| // TextCodecLatin1 registers them.
|
| - // FIXME: We may introduce SYSTEM_ICU and enclose this block
|
| - // with |#if SYSTEM_ICU| because Chromium's ICU has them all.
|
| registrar("csiso58gb231280", "GBK");
|
| registrar("csiso88596e", "ISO-8859-6");
|
| registrar("csiso88596i", "ISO-8859-6");
|
| @@ -212,6 +220,7 @@ void TextCodecICU::registerEncodingNames(EncodingNameRegistrar registrar)
|
| registrar("x-cp1256", "windows-1256");
|
| registrar("x-cp1257", "windows-1257");
|
| registrar("x-cp1258", "windows-1258");
|
| +#endif
|
| }
|
|
|
| void TextCodecICU::registerCodecs(TextCodecRegistrar registrar)
|
|
|