Changeset 266651 in webkit


Ignore:
Timestamp:
Sep 4, 2020 7:51:05 PM (4 years ago)
Author:
achristensen@apple.com
Message:

Align KOI8-U and ibm866 encodings with Chrome, Firefox, and the specification
https://bugs.webkit.org/show_bug.cgi?id=216184

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

  • web-platform-tests/encoding/single-byte-decoder-expected.txt:

Source/WebCore:

Covered by newly passing web platform tests.

  • platform/text/TextCodecICU.cpp:
  • platform/text/TextCodecSingleByte.cpp:

(WebCore::tableForEncoding):
(WebCore::tableForDecoding):
(WebCore::TextCodecSingleByte::registerEncodingNames):
(WebCore::TextCodecSingleByte::registerCodecs):

  • platform/text/TextCodecSingleByte.h:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r266627 r266651  
     12020-09-04  Alex Christensen  <achristensen@webkit.org>
     2
     3        Align KOI8-U and ibm866 encodings with Chrome, Firefox, and the specification
     4        https://bugs.webkit.org/show_bug.cgi?id=216184
     5
     6        Reviewed by Darin Adler.
     7
     8        * web-platform-tests/encoding/single-byte-decoder-expected.txt:
     9
    1102020-09-04  Chris Dumez  <cdumez@apple.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/single-byte-decoder-expected.txt

    r266527 r266651  
    11
    2 FAIL IBM866: 866 (XMLHttpRequest) assert_equals: IBM866:26 expected 26 but got 28
    3 FAIL IBM866: 866 (TextDecoder) assert_equals: IBM866:26 expected 26 but got 28
     2PASS IBM866: 866 (XMLHttpRequest)
     3PASS IBM866: 866 (TextDecoder)
    44PASS IBM866: 866 (document.characterSet and document.inputEncoding)
    5 FAIL IBM866: cp866 (XMLHttpRequest) assert_equals: IBM866:26 expected 26 but got 28
    6 FAIL IBM866: cp866 (TextDecoder) assert_equals: IBM866:26 expected 26 but got 28
     5PASS IBM866: cp866 (XMLHttpRequest)
     6PASS IBM866: cp866 (TextDecoder)
    77PASS IBM866: cp866 (document.characterSet and document.inputEncoding)
    8 FAIL IBM866: csibm866 (XMLHttpRequest) assert_equals: IBM866:26 expected 26 but got 28
    9 FAIL IBM866: csibm866 (TextDecoder) assert_equals: IBM866:26 expected 26 but got 28
     8PASS IBM866: csibm866 (XMLHttpRequest)
     9PASS IBM866: csibm866 (TextDecoder)
    1010PASS IBM866: csibm866 (document.characterSet and document.inputEncoding)
    11 FAIL IBM866: ibm866 (XMLHttpRequest) assert_equals: IBM866:26 expected 26 but got 28
    12 FAIL IBM866: ibm866 (TextDecoder) assert_equals: IBM866:26 expected 26 but got 28
     11PASS IBM866: ibm866 (XMLHttpRequest)
     12PASS IBM866: ibm866 (TextDecoder)
    1313PASS IBM866: ibm866 (document.characterSet and document.inputEncoding)
    1414PASS ISO-8859-2: csisolatin2 (XMLHttpRequest)
     
    312312PASS KOI8-R: koi8_r (TextDecoder)
    313313PASS KOI8-R: koi8_r (document.characterSet and document.inputEncoding)
    314 FAIL KOI8-U: koi8-ru (XMLHttpRequest) assert_equals: KOI8-U:174 expected 1118 but got 9565
    315 FAIL KOI8-U: koi8-ru (TextDecoder) assert_equals: KOI8-U:174 expected 1118 but got 9565
     314PASS KOI8-U: koi8-ru (XMLHttpRequest)
     315PASS KOI8-U: koi8-ru (TextDecoder)
    316316PASS KOI8-U: koi8-ru (document.characterSet and document.inputEncoding)
    317 FAIL KOI8-U: koi8-u (XMLHttpRequest) assert_equals: KOI8-U:174 expected 1118 but got 9565
    318 FAIL KOI8-U: koi8-u (TextDecoder) assert_equals: KOI8-U:174 expected 1118 but got 9565
     317PASS KOI8-U: koi8-u (XMLHttpRequest)
     318PASS KOI8-U: koi8-u (TextDecoder)
    319319PASS KOI8-U: koi8-u (document.characterSet and document.inputEncoding)
    320320PASS macintosh: csmacintosh (XMLHttpRequest)
  • trunk/Source/WebCore/ChangeLog

    r266649 r266651  
     12020-09-04  Alex Christensen  <achristensen@webkit.org>
     2
     3        Align KOI8-U and ibm866 encodings with Chrome, Firefox, and the specification
     4        https://bugs.webkit.org/show_bug.cgi?id=216184
     5
     6        Reviewed by Darin Adler.
     7
     8        Covered by newly passing web platform tests.
     9
     10        * platform/text/TextCodecICU.cpp:
     11        * platform/text/TextCodecSingleByte.cpp:
     12        (WebCore::tableForEncoding):
     13        (WebCore::tableForDecoding):
     14        (WebCore::TextCodecSingleByte::registerEncodingNames):
     15        (WebCore::TextCodecSingleByte::registerCodecs):
     16        * platform/text/TextCodecSingleByte.h:
     17
    1182020-09-04  Sam Weinig  <weinig@apple.com>
    219
  • trunk/Source/WebCore/platform/text/TextCodecICU.cpp

    r266527 r266651  
    4747
    4848// From https://encoding.spec.whatwg.org. Plus a few extra aliases that macOS had historically from TEC.
    49 DECLARE_ALIASES(IBM866, "866", "cp866", "csibm866");
    5049DECLARE_ALIASES(ISO_8859_2, "csisolatin2", "iso-ir-101", "iso8859-2", "iso88592", "iso_8859-2", "iso_8859-2:1987", "l2", "latin2");
    5150DECLARE_ALIASES(ISO_8859_4, "csisolatin4", "iso-ir-110", "iso8859-4", "iso88594", "iso_8859-4", "iso_8859-4:1988", "l4", "latin4");
     
    5756DECLARE_ALIASES(ISO_8859_16, "isoir226", "iso8859162001", "l10", "latin10");
    5857DECLARE_ALIASES(KOI8_R, "cskoi8r", "koi", "koi8", "koi8_r");
    59 DECLARE_ALIASES(KOI8_U, "koi8-ru");
    6058DECLARE_ALIASES(macintosh, "csmacintosh", "mac", "x-mac-roman", "macroman", "x-macroman");
    6159DECLARE_ALIASES(windows_1250, "cp1250", "x-cp1250", "winlatin2");
     
    8381    const char* const * aliases;
    8482} encodingNames[] = {
    85     DECLARE_ENCODING_NAME("IBM866", IBM866),
    8683    DECLARE_ENCODING_NAME("ISO-8859-2", ISO_8859_2),
    8784    DECLARE_ENCODING_NAME("ISO-8859-4", ISO_8859_4),
     
    9390    DECLARE_ENCODING_NAME("ISO-8859-16", ISO_8859_16),
    9491    DECLARE_ENCODING_NAME("KOI8-R", KOI8_R),
    95     DECLARE_ENCODING_NAME("KOI8-U", KOI8_U),
    9692    DECLARE_ENCODING_NAME("macintosh", macintosh),
    9793    DECLARE_ENCODING_NAME("windows-1250", windows_1250),
  • trunk/Source/WebCore/platform/text/TextCodecSingleByte.cpp

    r266527 r266651  
    128128};
    129129
     130// From https://encoding.spec.whatwg.org/index-koi8-u.txt
     131constexpr UChar koi8u[128] {
     132    0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524, 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
     133    0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219, 0x221A, 0x2248, 0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7,
     134    0x2550, 0x2551, 0x2552, 0x0451, 0x0454, 0x2554, 0x0456, 0x0457, 0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x0491, 0x045E, 0x255E,
     135    0x255F, 0x2560, 0x2561, 0x0401, 0x0404, 0x2563, 0x0406, 0x0407, 0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x0490, 0x040E, 0x00A9,
     136    0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, 0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E,
     137    0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, 0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A,
     138    0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E,
     139    0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A
     140};
     141
     142// From https://encoding.spec.whatwg.org/index-ibm866.txt
     143constexpr UChar ibm866[128] {
     144    0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
     145    0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
     146    0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
     147    0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
     148    0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
     149    0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
     150    0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
     151    0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0
     152};
     153
    130154template<const UChar* decodeTable>
    131155std::pair<const std::pair<UChar, uint8_t>*, size_t> tableForEncoding()
     
    171195    case TextCodecSingleByte::Encoding::Windows_1257:
    172196        return tableForEncoding<windows1257>();
     197    case TextCodecSingleByte::Encoding::IBM866:
     198        return tableForEncoding<ibm866>();
     199    case TextCodecSingleByte::Encoding::KOI8U:
     200        return tableForEncoding<koi8u>();
    173201    }
    174202    ASSERT_NOT_REACHED();
     
    195223    case TextCodecSingleByte::Encoding::Windows_1257:
    196224        return windows1257;
     225    case TextCodecSingleByte::Encoding::IBM866:
     226        return ibm866;
     227    case TextCodecSingleByte::Encoding::KOI8U:
     228        return koi8u;
    197229    }
    198230    ASSERT_NOT_REACHED();
     
    372404        "x-cp1257"
    373405    });
     406   
     407    registerAliases({
     408        "KOI8-U",
     409        "koi8-ru"
     410    });
     411
     412    registerAliases({
     413        "IBM866",
     414        "866",
     415        "cp866",
     416        "csibm866"
     417    });
    374418}
    375419
     
    403447        return makeUnique<TextCodecSingleByte>(Encoding::Windows_1257);
    404448    });
    405 }
    406 
    407 }
     449    registrar("KOI8-U", [] {
     450        return makeUnique<TextCodecSingleByte>(Encoding::KOI8U);
     451    });
     452    registrar("IBM866", [] {
     453        return makeUnique<TextCodecSingleByte>(Encoding::IBM866);
     454    });
     455}
     456
     457}
  • trunk/Source/WebCore/platform/text/TextCodecSingleByte.h

    r266527 r266651  
    4040        Windows_1253,
    4141        Windows_1255,
    42         Windows_1257
     42        Windows_1257,
     43        IBM866,
     44        KOI8U,
    4345    };
    4446
Note: See TracChangeset for help on using the changeset viewer.