functionalscript 0.0.386 → 0.0.387
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/text/encoding/README.md +11 -11
- package/text/encoding/module.f.cjs +46 -46
- package/text/encoding/test.f.cjs +72 -62
package/package.json
CHANGED
package/text/encoding/README.md
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
Requirement: no loss for UTF8 => codepoint => UTF8
|
|
6
6
|
|
|
7
|
-
|utf8 |
|
|
7
|
+
|utf8 |utf8 code |size |codepoint |
|
|
8
8
|
|---------|---------------------------------------|---------|--------------------------------------------------|
|
|
9
9
|
|[a] |0xxx_xxxx |7 bit |0_0000_0000_0000_0xxx_xxxx |
|
|
10
10
|
|[b,a] |110x_xxxx 10xx_xxxx |11 bit |0_0000_0000_0xxx_xxxx_xxxx + 0_0000_0000_1000_0000|
|
|
11
11
|
|[c,b,a] |1110_xxxx 10xx_xxxx 10xx_xxxx |16 bit |0_0000_xxxx_xxxx_xxxx_xxxx + 0_0000_1000_0000_0000|
|
|
12
12
|
|[d,c,b,a]|1111_0xxx 10xx_xxxx 10xx_xxxx 10xx_xxxx|21 bit |x_xxxx_xxxx_xxxx_xxxx_xxxx + 1_0000_0000_0000_0000|
|
|
13
13
|
|
|
14
|
-
|utf8 error|
|
|
14
|
+
|utf8 error|utf8 code |size |codepoint |
|
|
15
15
|
|----------|-----------------------------|------|-------------------|
|
|
16
16
|
|[e] |1111_1xxx | 3 bit| |
|
|
17
17
|
|[d,] |1111_0xxx | 3 bit| |
|
|
@@ -55,15 +55,15 @@ Requirement: no loss for UTF16 => codepoint => UTF16
|
|
|
55
55
|
- first : 0xD800: 0b_1101_10xx_xxxx_xxxx : 10 bit
|
|
56
56
|
- second: 0xDC00: 0b_1101_11xx_xxxx_xxxx : 10 bit
|
|
57
57
|
|
|
58
|
-
|utf16 |
|
|
59
|
-
|
|
60
|
-
|[a] |xxxx_xxxx_xxxx_xxxx |16 bit|
|
|
61
|
-
|[b,a] |1101_10xx_xxxx_xxxx 1101_11xx_xxxx_xxxx|20 bit|
|
|
58
|
+
|utf16 |utf16 code |size |codepoint |
|
|
59
|
+
|---------|---------------------------------------|------|------------------------------------------------|
|
|
60
|
+
|[a] |xxxx_xxxx_xxxx_xxxx |16 bit|0000_xxxx_xxxx_xxxx_xxxx |
|
|
61
|
+
|[b,a] |1101_10xx_xxxx_xxxx 1101_11xx_xxxx_xxxx|20 bit|xxxx_xxxx_xxxx_xxxx_xxxx + 1_0000_0000_0000_0000|
|
|
62
62
|
|
|
63
|
-
|utf16 error|
|
|
64
|
-
|
|
65
|
-
|[e] |1101_11xx_xxxx_xxxx|10 bit|
|
|
66
|
-
|[b,] |1101_10xx_xxxx_xxxx|10 bit|
|
|
63
|
+
|utf16 error|utf16 code |size |codepoint |
|
|
64
|
+
|-----------|-------------------|------|-------------------|
|
|
65
|
+
|[e] |1101_11xx_xxxx_xxxx|10 bit|1101_11xx_xxxx_xxxx|
|
|
66
|
+
|[b,] |1101_10xx_xxxx_xxxx|10 bit|1101_10xx_xxxx_xxxx|
|
|
67
67
|
|
|
68
68
|
Total error states: 11 bit
|
|
69
69
|
|
|
@@ -74,7 +74,7 @@ const utf16ListToCodePointList
|
|
|
74
74
|
/** @type {(input: List<i32>) => List<u16>} */
|
|
75
75
|
const codePointListToUtf16List
|
|
76
76
|
|
|
77
|
-
/** @type {(input: string) => List<u16> */
|
|
77
|
+
/** @type {(input: string) => List<u16>} */
|
|
78
78
|
const stringToUtf16List
|
|
79
79
|
|
|
80
80
|
/** @type {(input: List<u16>) => string} */
|
|
@@ -11,9 +11,15 @@ const { ok, error } = result
|
|
|
11
11
|
|
|
12
12
|
/** @typedef {number|undefined} ByteOrEof */
|
|
13
13
|
|
|
14
|
+
/** @typedef {u16|undefined} WordOrEof */
|
|
15
|
+
|
|
14
16
|
/** @typedef {undefined|array.Array1<number>|array.Array2<number>|array.Array3<number>} Utf8State */
|
|
15
17
|
|
|
16
|
-
/** @typedef {undefined|
|
|
18
|
+
/** @typedef {undefined|number} Utf16State */
|
|
19
|
+
|
|
20
|
+
/** @typedef {number} u16 */
|
|
21
|
+
|
|
22
|
+
/** @typedef {number} i32 */
|
|
17
23
|
|
|
18
24
|
/** @type {(a:number) => boolean} */
|
|
19
25
|
const isBmpCodePoint = a => a >= 0x0000 && a <= 0xd7ff || a >= 0xe000 && a <= 0xffff
|
|
@@ -23,6 +29,8 @@ const isHighSurrogate = contains([0xd800, 0xdbff])
|
|
|
23
29
|
/** @type {(a:number) => boolean} */
|
|
24
30
|
const isLowSurrogate = contains([0xdc00, 0xdfff])
|
|
25
31
|
|
|
32
|
+
const errorMask = 0b1000_0000_0000_0000_0000_0000_0000_0000
|
|
33
|
+
|
|
26
34
|
/** @type {(input:number) => list.List<ByteResult>} */
|
|
27
35
|
const codePointToUtf8 = input =>
|
|
28
36
|
{
|
|
@@ -33,29 +41,29 @@ const codePointToUtf8 = input =>
|
|
|
33
41
|
return [error(input)]
|
|
34
42
|
}
|
|
35
43
|
|
|
36
|
-
/** @type {(input:
|
|
44
|
+
/** @type {(input:i32) => list.List<u16>} */
|
|
37
45
|
const codePointToUtf16 = input =>
|
|
38
46
|
{
|
|
39
|
-
if (isBmpCodePoint(input)) { return [
|
|
47
|
+
if (isBmpCodePoint(input)) { return [input] }
|
|
40
48
|
if (input >= 0x010000 && input <= 0x10ffff) {
|
|
41
49
|
const high = ((input - 0x10000) >> 10) + 0xd800
|
|
42
|
-
const low = ((input - 0x10000) &
|
|
43
|
-
return [
|
|
50
|
+
const low = ((input - 0x10000) & 0b0011_1111_1111) + 0xdc00
|
|
51
|
+
return [high, low]
|
|
44
52
|
}
|
|
45
|
-
return [
|
|
53
|
+
return [input & 0xffff]
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
/** @type {(input: list.List<number>) => list.List<ByteResult>} */
|
|
49
|
-
const
|
|
57
|
+
const codePointListToUtf8List = list.flatMap(codePointToUtf8)
|
|
50
58
|
|
|
51
|
-
/** @type {(input: list.List<
|
|
52
|
-
const
|
|
59
|
+
/** @type {(input: list.List<i32>) => list.List<u16>} */
|
|
60
|
+
const codePointListToUtf16List = list.flatMap(codePointToUtf16)
|
|
53
61
|
|
|
54
62
|
/** @type {operator.StateScan<number, Utf8State, list.List<CodePointResult>>} */
|
|
55
63
|
const utf8ByteToCodePointOp = state => byte => {
|
|
56
64
|
if (byte < 0x00 || byte > 0xff) {
|
|
57
65
|
return [[error([byte])], state]
|
|
58
|
-
}
|
|
66
|
+
}
|
|
59
67
|
if (state == undefined) {
|
|
60
68
|
if (byte < 0x80) { return [[ok(byte)], undefined] }
|
|
61
69
|
if (byte >= 0xc2 && byte <= 0xf4) { return [[], [byte]] }
|
|
@@ -68,71 +76,63 @@ const utf8ByteToCodePointOp = state => byte => {
|
|
|
68
76
|
case 1:
|
|
69
77
|
if (state[0] < 0xe0) { return [[ok(((state[0] & 0x1f) << 6) + (byte & 0x3f))], undefined] }
|
|
70
78
|
if (state[0] < 0xf8) { return [[], [state[0], byte]] }
|
|
71
|
-
break
|
|
79
|
+
break
|
|
72
80
|
case 2:
|
|
73
81
|
if (state[0] < 0xf0) { return [[ok(((state[0] & 0x0f) << 12) + ((state[1] & 0x3f) << 6) + (byte & 0x3f))], undefined] }
|
|
74
82
|
if (state[0] < 0xf8) { return [[], [state[0], state[1], byte]] }
|
|
75
83
|
break
|
|
76
|
-
case 3:
|
|
84
|
+
case 3:
|
|
77
85
|
return [[ok(((state[0] & 0x07) << 18) + ((state[1] & 0x3f) << 12) + ((state[2] & 0x3f) << 6) + (byte & 0x3f))], undefined]
|
|
78
86
|
}
|
|
79
|
-
}
|
|
87
|
+
}
|
|
80
88
|
return [[error(list.toArray(list.concat(state)([byte])))], undefined]
|
|
81
89
|
}
|
|
82
90
|
|
|
83
91
|
/** @type {(state: Utf8State) => readonly[list.List<CodePointResult>, Utf8State]} */
|
|
84
|
-
const utf8EofToCodePointOp = state => [state
|
|
92
|
+
const utf8EofToCodePointOp = state => [state === undefined ? undefined : [error(state)], undefined]
|
|
85
93
|
|
|
86
94
|
/** @type {operator.StateScan<ByteOrEof, Utf8State, list.List<CodePointResult>>} */
|
|
87
95
|
const utf8ByteOrEofToCodePointOp = state => input => input === undefined ? utf8EofToCodePointOp(state) : utf8ByteToCodePointOp(state)(input)
|
|
88
96
|
|
|
89
97
|
/** @type {(input: list.List<number>) => list.List<CodePointResult>} */
|
|
90
|
-
const
|
|
98
|
+
const utf8ListToCodePointList = input => list.flat(list.stateScan(utf8ByteOrEofToCodePointOp)(undefined)(list.concat(/** @type {list.List<ByteOrEof>} */(input))([undefined])))
|
|
91
99
|
|
|
92
|
-
/** @type {operator.StateScan<
|
|
100
|
+
/** @type {operator.StateScan<u16, Utf16State, list.List<i32>>} */
|
|
93
101
|
const utf16ByteToCodePointOp = state => byte => {
|
|
94
|
-
if (byte < 0x00 || byte >
|
|
95
|
-
return [[
|
|
102
|
+
if (byte < 0x00 || byte > 0xffff) {
|
|
103
|
+
return [[0xffffffff], state]
|
|
96
104
|
}
|
|
97
|
-
if (state
|
|
98
|
-
return [[],
|
|
105
|
+
if (state === undefined) {
|
|
106
|
+
if (isBmpCodePoint(byte)) { return [[byte], undefined] }
|
|
107
|
+
if (isHighSurrogate(byte)) { return [[], byte] }
|
|
108
|
+
return [[byte | errorMask], undefined]
|
|
99
109
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (isBmpCodePoint(codeUnit)) { return [[ok(codeUnit)], undefined] }
|
|
105
|
-
if (isHighSurrogate(codeUnit)) { return [[], [state[0], byte]] }
|
|
106
|
-
break
|
|
107
|
-
case 2:
|
|
108
|
-
return [[], [state[0], state[1], byte]]
|
|
109
|
-
case 3:
|
|
110
|
-
if (isLowSurrogate((state[2] << 8) + byte)) {
|
|
111
|
-
const high = (state[0] << 8) + state[1] - 0xd800
|
|
112
|
-
const low = (state[2] << 8) + byte - 0xdc00
|
|
113
|
-
return [[ok((high << 10) + low + 0x10000)], undefined]
|
|
114
|
-
}
|
|
115
|
-
break
|
|
110
|
+
if (isLowSurrogate(byte)) {
|
|
111
|
+
const high = state - 0xd800
|
|
112
|
+
const low = byte - 0xdc00
|
|
113
|
+
return [[(high << 10) + low + 0x10000], undefined]
|
|
116
114
|
}
|
|
117
|
-
return [[
|
|
115
|
+
if (isBmpCodePoint(byte)) { return [[state | errorMask, byte], undefined] }
|
|
116
|
+
if (isHighSurrogate(byte)) { return [[state | errorMask], byte] }
|
|
117
|
+
return [[state | errorMask, byte | errorMask], undefined]
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
/** @type {(state:
|
|
121
|
-
const utf16EofToCodePointOp = state => [state
|
|
120
|
+
/** @type {(state: Utf16State) => readonly[list.List<i32>, Utf16State]} */
|
|
121
|
+
const utf16EofToCodePointOp = state => [state === undefined ? undefined : [state | errorMask], undefined]
|
|
122
122
|
|
|
123
|
-
/** @type {operator.StateScan<
|
|
123
|
+
/** @type {operator.StateScan<WordOrEof, Utf16State, list.List<i32>>} */
|
|
124
124
|
const utf16ByteOrEofToCodePointOp = state => input => input === undefined ? utf16EofToCodePointOp(state) : utf16ByteToCodePointOp(state)(input)
|
|
125
125
|
|
|
126
|
-
/** @type {(input: list.List<
|
|
127
|
-
const
|
|
126
|
+
/** @type {(input: list.List<u16>) => list.List<i32>} */
|
|
127
|
+
const utf16ListToCodePointList = input => list.flat(list.stateScan(utf16ByteOrEofToCodePointOp)(undefined)(list.concat(/** @type {list.List<WordOrEof>} */(input))([undefined])))
|
|
128
128
|
|
|
129
129
|
module.exports = {
|
|
130
130
|
/** @readonly */
|
|
131
|
-
|
|
131
|
+
codePointListToUtf8List,
|
|
132
132
|
/** @readonly */
|
|
133
|
-
|
|
133
|
+
codePointListToUtf16List,
|
|
134
134
|
/** @readonly */
|
|
135
|
-
|
|
135
|
+
utf8ListToCodePointList,
|
|
136
136
|
/** @readonly */
|
|
137
|
-
|
|
137
|
+
utf16ListToCodePointList
|
|
138
138
|
}
|
package/text/encoding/test.f.cjs
CHANGED
|
@@ -7,193 +7,203 @@ const { list } = require('../../types/module.f.cjs')
|
|
|
7
7
|
const stringify = a => json.stringify(sort)(a)
|
|
8
8
|
|
|
9
9
|
{
|
|
10
|
-
const result = stringify(list.toArray(encoding.
|
|
10
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8List([0,1,0x7F])))
|
|
11
11
|
if (result !== '[["ok",0],["ok",1],["ok",127]]') { throw result }
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
{
|
|
15
|
-
const result = stringify(list.toArray(encoding.
|
|
15
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8List([0x80])))
|
|
16
16
|
if (result !== '[["ok",194],["ok",128]]') { throw result }
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
{
|
|
20
|
-
const result = stringify(list.toArray(encoding.
|
|
20
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8List([0xa9])))
|
|
21
21
|
if (result !== '[["ok",194],["ok",169]]') { throw result }
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
{
|
|
25
|
-
const result = stringify(list.toArray(encoding.
|
|
25
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8List([0x7ff])))
|
|
26
26
|
if (result !== '[["ok",223],["ok",191]]') { throw result }
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
{
|
|
30
|
-
const result = stringify(list.toArray(encoding.
|
|
30
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8List([0x800])))
|
|
31
31
|
if (result !== '[["ok",224],["ok",160],["ok",128]]') { throw result }
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
{
|
|
35
|
-
const result = stringify(list.toArray(encoding.
|
|
35
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8List([0x801])))
|
|
36
36
|
if (result !== '[["ok",224],["ok",160],["ok",129]]') { throw result }
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
{
|
|
40
|
-
const result = stringify(list.toArray(encoding.
|
|
40
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8List([0xffff])))
|
|
41
41
|
if (result !== '[["ok",239],["ok",191],["ok",191]]') { throw result }
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
{
|
|
45
|
-
const result = stringify(list.toArray(encoding.
|
|
45
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8List([0x10000])))
|
|
46
46
|
if (result !== '[["ok",240],["ok",144],["ok",128],["ok",128]]') { throw result }
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
{
|
|
50
|
-
const result = stringify(list.toArray(encoding.
|
|
50
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8List([0x10001])))
|
|
51
51
|
if (result !== '[["ok",240],["ok",144],["ok",128],["ok",129]]') { throw result }
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
{
|
|
55
|
-
const result = stringify(list.toArray(encoding.
|
|
55
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8List([0x10FFFF])))
|
|
56
56
|
if (result !== '[["ok",244],["ok",143],["ok",191],["ok",191]]') { throw result }
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
{
|
|
60
|
-
const result = stringify(list.toArray(encoding.
|
|
60
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8List([-1,0x110000])))
|
|
61
61
|
if (result !== '[["error",-1],["error",1114112]]') { throw result }
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
{
|
|
65
|
-
const result = stringify(list.toArray(encoding.
|
|
66
|
-
if (result !== '[
|
|
65
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16List([0])))
|
|
66
|
+
if (result !== '[0]') { throw result }
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
{
|
|
70
|
-
const result = stringify(list.toArray(encoding.
|
|
71
|
-
if (result !== '[
|
|
70
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16List([0x24])))
|
|
71
|
+
if (result !== '[36]') { throw result }
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
{
|
|
75
|
-
const result = stringify(list.toArray(encoding.
|
|
76
|
-
if (result !== '[
|
|
75
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16List([0x20AC])))
|
|
76
|
+
if (result !== '[8364]') { throw result }
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
{
|
|
80
|
-
const result = stringify(list.toArray(encoding.
|
|
81
|
-
if (result !== '[
|
|
80
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16List([0xd7ff])))
|
|
81
|
+
if (result !== '[55295]') { throw result }
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
{
|
|
85
|
-
const result = stringify(list.toArray(encoding.
|
|
86
|
-
if (result !== '[
|
|
85
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16List([0xe000])))
|
|
86
|
+
if (result !== '[57344]') { throw result }
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
{
|
|
90
|
-
const result = stringify(list.toArray(encoding.
|
|
91
|
-
if (result !== '[
|
|
90
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16List([0xffff])))
|
|
91
|
+
if (result !== '[65535]') { throw result }
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
{
|
|
95
|
-
const result = stringify(list.toArray(encoding.
|
|
96
|
-
if (result !== '[
|
|
95
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16List([0x10000])))
|
|
96
|
+
if (result !== '[55296,56320]') { throw result }
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
{
|
|
100
|
-
const result = stringify(list.toArray(encoding.
|
|
101
|
-
if (result !== '[
|
|
100
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16List([0x10437])))
|
|
101
|
+
if (result !== '[55297,56375]') { throw result }
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
{
|
|
105
|
-
const result = stringify(list.toArray(encoding.
|
|
106
|
-
if (result !== '[
|
|
105
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16List([0x24B62])))
|
|
106
|
+
if (result !== '[55378,57186]') { throw result }
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
{
|
|
110
|
-
const result = stringify(list.toArray(encoding.
|
|
111
|
-
if (result !== '[
|
|
110
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16List([0x10ffff])))
|
|
111
|
+
if (result !== '[56319,57343]') { throw result }
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
{
|
|
115
|
-
const result = stringify(list.toArray(encoding.
|
|
116
|
-
if (result !== '[
|
|
115
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16List([-1, 0xd800, 0xdfff, 0x110000])))
|
|
116
|
+
if (result !== '[65535,55296,57343,0]') { throw result }
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
{
|
|
120
|
-
const result = stringify(list.toArray(encoding.
|
|
119
|
+
{
|
|
120
|
+
const result = stringify(list.toArray(encoding.utf8ListToCodePointList([-1, 256])))
|
|
121
121
|
if (result !== '[["error",[-1]],["error",[256]]]') { throw result }
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
{
|
|
125
|
-
const result = stringify(list.toArray(encoding.
|
|
124
|
+
{
|
|
125
|
+
const result = stringify(list.toArray(encoding.utf8ListToCodePointList([128, 193, 245, 255])))
|
|
126
126
|
if (result !== '[["error",[128]],["error",[193]],["error",[245]],["error",[255]]]') { throw result }
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
{
|
|
130
|
-
const result = stringify(list.toArray(encoding.
|
|
129
|
+
{
|
|
130
|
+
const result = stringify(list.toArray(encoding.utf8ListToCodePointList([0, 1, 127])))
|
|
131
131
|
if (result !== '[["ok",0],["ok",1],["ok",127]]') { throw result }
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
{
|
|
135
|
-
const result = stringify(list.toArray(encoding.
|
|
135
|
+
const result = stringify(list.toArray(encoding.utf8ListToCodePointList([194, 128, 194, 169, 223, 191])))
|
|
136
136
|
if (result !== '[["ok",128],["ok",169],["ok",2047]]') { throw result }
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
{
|
|
140
|
-
const result = stringify(list.toArray(encoding.
|
|
139
|
+
{
|
|
140
|
+
const result = stringify(list.toArray(encoding.utf8ListToCodePointList([194, 127, 194, 192, 194])))
|
|
141
141
|
if (result !== '[["error",[194,127]],["error",[194,192]],["error",[194]]]') { throw result }
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
{
|
|
145
|
-
const result = stringify(list.toArray(encoding.
|
|
145
|
+
const result = stringify(list.toArray(encoding.utf8ListToCodePointList([224, 160, 128, 224, 160, 129, 239, 191, 191])))
|
|
146
146
|
if (result !== '[["ok",2048],["ok",2049],["ok",65535]]') { throw result }
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
{
|
|
150
|
-
const result = stringify(list.toArray(encoding.
|
|
149
|
+
{
|
|
150
|
+
const result = stringify(list.toArray(encoding.utf8ListToCodePointList([224, 160, 127, 224, 160, 192, 224, 160])))
|
|
151
151
|
if (result !== '[["error",[224,160,127]],["error",[224,160,192]],["error",[224,160]]]') { throw result }
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
{
|
|
155
|
-
const result = stringify(list.toArray(encoding.
|
|
155
|
+
const result = stringify(list.toArray(encoding.utf8ListToCodePointList([240, 144, 128, 128, 240, 144, 128, 129, 244, 143, 191, 191])))
|
|
156
156
|
if (result !== '[["ok",65536],["ok",65537],["ok",1114111]]') { throw result }
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
{
|
|
160
|
-
const result = stringify(list.toArray(encoding.
|
|
159
|
+
{
|
|
160
|
+
const result = stringify(list.toArray(encoding.utf8ListToCodePointList([240, 144, 128, 127, 240, 144, 128, 192, 240, 144, 128])))
|
|
161
161
|
if (result !== '[["error",[240,144,128,127]],["error",[240,144,128,192]],["error",[240,144,128]]]') { throw result }
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
{
|
|
165
|
-
const result = stringify(list.toArray(encoding.
|
|
165
|
+
const result = stringify(list.toArray(encoding.utf8ListToCodePointList([194, -1, 128])))
|
|
166
166
|
if (result !== '[["error",[-1]],["ok",128]]') { throw result }
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
{
|
|
170
|
-
const result = stringify(list.toArray(encoding.
|
|
171
|
-
if (result !== '[
|
|
169
|
+
{
|
|
170
|
+
const result = stringify(list.toArray(encoding.utf16ListToCodePointList([-1, 65536])))
|
|
171
|
+
if (result !== '[4294967295,4294967295]') { throw result }
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
{
|
|
175
|
+
const result = stringify(list.toArray(encoding.utf16ListToCodePointList([0, 36, 8364, 55295, 57344, 65535])))
|
|
176
|
+
if (result !== '[0,36,8364,55295,57344,65535]') { throw result }
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
{
|
|
180
|
+
const result = stringify(list.toArray(encoding.utf16ListToCodePointList([56320, 57343])))
|
|
181
|
+
if (result !== '[-2147427328,-2147426305]') { throw result }
|
|
172
182
|
}
|
|
173
183
|
|
|
174
184
|
{
|
|
175
|
-
const result = stringify(list.toArray(encoding.
|
|
176
|
-
if (result !== '[
|
|
185
|
+
const result = stringify(list.toArray(encoding.utf16ListToCodePointList([55296, 56320, 55297, 56375, 55378, 57186, 56319, 57343])))
|
|
186
|
+
if (result !== '[65536,66615,150370,1114111]') { throw result }
|
|
177
187
|
}
|
|
178
188
|
|
|
179
189
|
{
|
|
180
|
-
const result = stringify(list.toArray(encoding.
|
|
181
|
-
if (result !== '[
|
|
190
|
+
const result = stringify(list.toArray(encoding.utf16ListToCodePointList([55296, 55296])))
|
|
191
|
+
if (result !== '[-2147428352,-2147428352]') { throw result }
|
|
182
192
|
}
|
|
183
193
|
|
|
184
194
|
{
|
|
185
|
-
const result = stringify(list.toArray(encoding.
|
|
186
|
-
if (result !== '[
|
|
195
|
+
const result = stringify(list.toArray(encoding.utf16ListToCodePointList([55296, 0])))
|
|
196
|
+
if (result !== '[-2147428352,0]') { throw result }
|
|
187
197
|
}
|
|
188
198
|
|
|
189
199
|
{
|
|
190
|
-
const result = stringify(list.toArray(encoding.
|
|
191
|
-
if (result !== '[
|
|
200
|
+
const result = stringify(list.toArray(encoding.utf16ListToCodePointList([56320])))
|
|
201
|
+
if (result !== '[-2147427328]') { throw result }
|
|
192
202
|
}
|
|
193
203
|
|
|
194
204
|
{
|
|
195
|
-
const result = stringify(list.toArray(encoding.
|
|
196
|
-
if (result !== '[
|
|
205
|
+
const result = stringify(list.toArray(encoding.utf16ListToCodePointList([56320, 0])))
|
|
206
|
+
if (result !== '[-2147427328,0]') { throw result }
|
|
197
207
|
}
|
|
198
208
|
|
|
199
209
|
module.exports = {}
|