Chromium Code Reviews| Index: third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp |
| diff --git a/third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp b/third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp |
| index f0d9ccce852814c9fe7314361b4b12cbcbceec9e..c90f000243f5dc8072c5d9e011031578be049f99 100644 |
| --- a/third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp |
| +++ b/third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp |
| @@ -62,13 +62,43 @@ bool detectTextEncoding(const char* data, |
| if (encoding == UNKNOWN_ENCODING || encoding == UTF8) |
| return false; |
| - // 7-bit encodings (except ISO-2022-JP) are not supported in WHATWG encoding |
| - // standard. Mark them as ASCII to keep the raw bytes intact. |
| + // Map all the Shift-JIS variants to Shift-JIS. |
| + if (hintUserLanguage && !strncmp(hintUserLanguage, "ja", 2) && |
| + IsShiftJisOrVariant(encoding)) { |
| + encoding = JAPANESE_SHIFT_JIS; |
| + } |
| + |
| + // 7-bit encodings (except ISO-2022-JP), and some obscure encodings not |
| + // supported in WHATWG encoding standard are marked as ASCII to keep the raw |
| + // bytes intact. |
| + // TODO(jinsukkim): Put this conversion into CED library, and enable "WHATWG" |
| + // mode. |
| switch (encoding) { |
| case HZ_GB_2312: |
| case ISO_2022_KR: |
| case ISO_2022_CN: |
| case UTF7: |
| + |
| + case CHINESE_EUC_DEC: |
| + case CHINESE_CNS: |
| + case CHINESE_BIG5_CP950: |
| + case MSFT_CP874: |
|
tkent
2017/03/08 03:43:37
We still need to list Shift_JIS variants for non-J
Jinsuk Kim
2017/03/08 04:05:54
Right. done.
|
| + case TSCII: |
| + case TAMIL_MONO: |
| + case TAMIL_BI: |
| + case JAGRAN: |
| + case BHASKAR: |
| + case HTCHANAKYA: |
| + case BINARYENC: |
| + case UTF8UTF8: |
| + case TAM_ELANGO: |
| + case TAM_LTTMBARANI: |
| + case TAM_SHREE: |
| + case TAM_TBOOMIS: |
| + case TAM_TMNEWS: |
| + case TAM_WEBTAMIL: |
| + case KDDI_ISO_2022_JP: |
| + case SOFTBANK_ISO_2022_JP: |
| encoding = ASCII_7BIT; |
| break; |
| default: |