/
507.txt
116 lines (88 loc) · 2.44 KB
/
507.txt
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
[SEE[ [[ISO/IEC 2022]] ]]
* ISO/IEC 2022 Decoder
[1] A [DFN[state]] is:
[FIG(list members)[
: [F[C0 designated]] : A [[character set]].
Initially, the [[initial C0 set]].
: [F[2/0 designated]] : [CODE(charname)@en[SP]] or [CODE(charname)@en[MSP]].
Initially, [CODE(charname)@en[SP]].
: [F[7/15 designated]] : [CODE(charname)@en[DEL]].
: [F[10/0 designated]] : [CODE(charname)@en[MSP]] or [CODE[null]].
Initially, [CODE[null]].
: [F[15/15 designated]] : [CODE[null]].
: [F[decoder state]] : One of [[decoder states][decoder state]].
Initially, [[initial state]].
]FIG]
[4]
To [DFN[emit a character]] [VAR[char]], run these steps:
[FIG(steps)[
=
[5]
If [VAR[char]] is [CODE[null]]:
==
@@ Error
==
[6]
@@ [CODE[U+FFFD]]?
=
[7]
Otherwise:
==
@@
]FIG]
@@
[FIG(steps)[
= [8] Let [VAR[state]] be a new [[state]].
= [9]
@@ Initialization steps
= [10]
@@
Process the input stream,
a sequence of zero or more [[bit combinations][bit combination]]
]FIG]
@@
** Decoder states
[2] There are the following [DFN[decoder states][decoder state]]:
*** Initial state
[3] The [DFN[initial state]] switches by the [[bit combination]] [VAR[bc]]:
[FIG(switch)[
: [ [N[0/0]], [N[1/15]] ] :
[FIG(steps)[
= [11] Let [VAR[set]] be [VAR[state]]'s [F[C0 designated]].
= [12] Let [VAR[char]] be [VAR[set]] [ [VAR[bc]] ].
= [13] [[Emit a character][emit a character]] [VAR[char]].
]FIG]
: [N[2/0]] :
[[Emit a character][emit a character]] [VAR[state]]'s [F[2/0 designated]].
: [N[7/15]] :
[[Emit a character][emit a character]] [VAR[state]]'s [F[7/15 designated]].
: [N[10/0]] :
[[Emit a character][emit a character]] [VAR[state]]'s [F[10/0 designated]].
: [N[15/15]] :
[[Emit a character][emit a character]] [VAR[state]]'s [F[15/15 designated]].
: Otherwise :
@@
]FIG]
* Definitions
[14]
This document depends on the [CITE[Infra Standard]].
[15]
The terms
[[byte]],
[[byte sequence]],
[[ordered map]],
[[key]],
and
[[value]]
are defined by the [CITE[Infra Standard]].
[16]
A [DFN[bit combination]] is a [[byte]].
A [[bit combination]] is represented as "[VAR[X]]/[VAR[Y]]",
where [VAR[X]] and [VAR[Y]] are integers in [ [N[0]], [N[15]] ],
which represents a [[byte]] [VAR[X]] × [N[16]] + [VAR[Y]].
** Character sets
[17]
A [DFN[character set]] is an [[ordered map]],
where [[keys][key]] are [[byte sequences][byte sequence]] and
[[values][value]] are a [[character]].
* Notes