blob: 928db94493b7b25597d02a92239f3b3825f2ebcb [file] [log] [blame]
utatane.tea@gmail.com9efa02e2016-06-07 17:23:11 +00001function shouldBe(actual, expected) {
2 if (actual !== expected)
3 throw new Error('bad value: ' + actual);
4}
5
6function toHighSurrogate(code)
7{
8 return (code >> 10) + (0xD800 - (0x10000 >> 10));
9}
10
11function toLowSurrogate(code)
12{
13 return (code & ((1 << 10) - 1)) + 0xDC00;
14}
15
16for (var i = 0x10000; i < 0x10ffff; ++i) {
17 var high = toHighSurrogate(i);
18 var low = toLowSurrogate(i);
19 var str = String.fromCharCode(high, low);
20 shouldBe(unescape(escape(str)), str);
21}