summaryrefslogtreecommitdiffstats
path: root/intl/uconv/tests/unit/test_decode_EUCKR_Hangul.js
blob: db0ba73b4dc9ecf9ffe521805154a29318eea6c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Tests conversion of 8-byte decomposed Hangul from EUC-KR (and variants)
// to Unicode, including invalid input
        
load('CharsetConversionTests.js');
load('hangulTestStrings.js');

const aliases = [ "euc-kr", "EUC-KR", "iso-ir-149", "ks_c_5601-1989", "ksc_5601", "ksc5601", "korean", "csksc56011987", "windows-949", "ks_c_5601-1987", "cseuckr"];

function to8byteHangul(byte3, byte5, byte7)
{
    return String.fromCharCode(0xa4, 0xd4, 0xa4, byte3, 0xa4, byte5, 0xa4, byte7);
}

function run_test() {
    var converter = CreateScriptableConverter();
    for (var i = 0; i < aliases.length; ++i) {
        var row = 0;
        for (var byte3 = 0xa0; byte3 < 0xc0; ++byte3) {
            for (var byte5 = 0xbe; byte5 < 0xd5; ++byte5) {
                var inString = " row " + byte3.toString(16) + "_" +
                    byte5.toString(16) + "_: ";
                for (var byte7 = 0xa0; byte7 < 0xc0; ++byte7) {
                    inString += to8byteHangul(byte3, byte5, byte7) + " ";
                }
                inString += to8byteHangul(byte3, byte5, 0xd4) + " ";
                checkDecode(converter, aliases[i], inString, expectedStrings[row++]);
            }
        }
        do_check_eq(row, expectedStrings.length);
    }
}