summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/encoding/char-encoding.html
blob: 31632cef6c1f6e74f2f140087d090f6303ce2ac4 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="resources/char-encoding-utils.js"></script>
</head>
<body>
<form id="form" method="GET" target="subframe"><input type="text" id="text" name="text"></form>
<iframe id="subframe" name="subframe"></iframe>
<script>


var charsets = new Array;
var unicodes = new Array;
var expectedResults = new Array;

var results = new Object;

var i = 0;


testEncode("UTF-8", "U+00A0", "%C2%A0");

// Unpaired UTF-16 surrogates
testEncode("UTF-8", "0xD800", "%EF%BF%BD"); // U+FFFD (REPLACEMENT CHARACTER)
testEncode("UTF-8", "0xDC00", "%EF%BF%BD"); // U+FFFD (REPLACEMENT CHARACTER)

//Yen symbol in gbk
testEncode('GBK', 'U+00A5', '%A3%A4');
testEncode('gb2312', 'U+00A5', '%A3%A4');
testEncode('GB_2312-80', 'U+00A5', '%A3%A4');
testEncode('EUC-CN', 'U+00A5', '%A3%A4');
//Euro symbol in gbk
testEncode('GBK', 'U+20AC', '%80');
testEncode('gb2312', 'U+20AC', '%80');
testEncode('GB_2312-80', 'U+20AC', '%80');
testEncode('EUC-CN', 'U+20AC', '%80');
//Align GBK with gb18030
// See https://www.w3.org/Bugs/Public/show_bug.cgi?id=28740#c3
testEncode('GBK', 'U+01F9', '%A8%BF');
testEncode('GBK', 'U+1E3F', '%A8%BC');
testEncode('gb18030', 'U+01F9', '%A8%BF');
testEncode('gb18030', 'U+1E3F', '%A8%BC');
testEncode('GBK', 'U+2026', '%A1%AD');
testEncode('GBK', 'U+FF5E', '%A1%AB');
testEncode('gb18030', 'U+2026', '%A1%AD');
testEncode('gb18030', 'U+FF5E', '%A1%AB');
// GBK does not cover these two characters.
testEncode('GBK', 'U+22EF', '%26%238943%3B');
testEncode('GBK', 'U+301C', '%26%2312316%3B');

// Big5: See https://www.w3.org/Bugs/Public/show_bug.cgi?id=27878
testEncode('Big5', 'U+2550', '%F9%F9');
testEncode('Big5', 'U+255E', '%F9%E9');
testEncode('Big5', 'U+2561', '%F9%EB');
testEncode('Big5', 'U+256A', '%F9%EA');
testEncode('Big5', 'U+5341', '%A4Q');
testEncode('Big5', 'U+5345', '%A4%CA');

// KOI8-U/KOI8-RU:  https://www.w3.org/Bugs/Public/show_bug.cgi?id=17053
testEncode('KOI8-U', 'U+045E', '%AE');
testEncode('KOI8-U', 'U+040E', '%BE');
testEncode('KOI8-RU', 'U+045E', '%AE');
testEncode('KOI8-RU', 'U+040E', '%BE');

// Replacement encodings - should encode as UTF-8
testEncode("csiso2022kr", "U+00A0", "%C2%A0");
testEncode("hz-gb-2312", "U+00A0", "%C2%A0");
testEncode("iso-2022-cn", "U+00A0", "%C2%A0");
testEncode("iso-2022-cn-ext", "U+00A0", "%C2%A0");
testEncode("iso-2022-kr", "U+00A0", "%C2%A0");

// Turning on this test causes a download to occur. FIXME: A bug?
// testEncode('UTF-8', 'U+221A', '%E2%88%9A');

if (window.testRunner)
    testRunner.waitUntilDone();
runTest();

</script>
</body>
</html>