Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/chardet/escsm.py: 95%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1######################## BEGIN LICENSE BLOCK ########################
2# The Original Code is mozilla.org code.
3#
4# The Initial Developer of the Original Code is
5# Netscape Communications Corporation.
6# Portions created by the Initial Developer are Copyright (C) 1998
7# the Initial Developer. All Rights Reserved.
8#
9# Contributor(s):
10# Mark Pilgrim - port to Python
11#
12# This library is free software; you can redistribute it and/or
13# modify it under the terms of the GNU Lesser General Public
14# License as published by the Free Software Foundation; either
15# version 2.1 of the License, or (at your option) any later version.
16#
17# This library is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20# Lesser General Public License for more details.
21#
22# You should have received a copy of the GNU Lesser General Public
23# License along with this library; if not, see
24# <https://www.gnu.org/licenses/>.
25######################### END LICENSE BLOCK #########################
27from .codingstatemachinedict import CodingStateMachineDict
28from .enums import MachineState
30# fmt: off
31HZ_CLS = (
32 1, 0, 0, 0, 0, 0, 0, 0, # 00 - 07
33 0, 0, 0, 0, 0, 0, 0, 0, # 08 - 0f
34 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 17
35 0, 0, 0, 1, 0, 0, 0, 0, # 18 - 1f
36 0, 0, 0, 0, 0, 0, 0, 0, # 20 - 27
37 0, 0, 0, 0, 0, 0, 0, 0, # 28 - 2f
38 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 37
39 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f
40 0, 0, 0, 0, 0, 0, 0, 0, # 40 - 47
41 0, 0, 0, 0, 0, 0, 0, 0, # 48 - 4f
42 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 57
43 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f
44 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 67
45 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f
46 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 77
47 0, 0, 0, 4, 0, 5, 2, 0, # 78 - 7f
48 1, 1, 1, 1, 1, 1, 1, 1, # 80 - 87
49 1, 1, 1, 1, 1, 1, 1, 1, # 88 - 8f
50 1, 1, 1, 1, 1, 1, 1, 1, # 90 - 97
51 1, 1, 1, 1, 1, 1, 1, 1, # 98 - 9f
52 1, 1, 1, 1, 1, 1, 1, 1, # a0 - a7
53 1, 1, 1, 1, 1, 1, 1, 1, # a8 - af
54 1, 1, 1, 1, 1, 1, 1, 1, # b0 - b7
55 1, 1, 1, 1, 1, 1, 1, 1, # b8 - bf
56 1, 1, 1, 1, 1, 1, 1, 1, # c0 - c7
57 1, 1, 1, 1, 1, 1, 1, 1, # c8 - cf
58 1, 1, 1, 1, 1, 1, 1, 1, # d0 - d7
59 1, 1, 1, 1, 1, 1, 1, 1, # d8 - df
60 1, 1, 1, 1, 1, 1, 1, 1, # e0 - e7
61 1, 1, 1, 1, 1, 1, 1, 1, # e8 - ef
62 1, 1, 1, 1, 1, 1, 1, 1, # f0 - f7
63 1, 1, 1, 1, 1, 1, 1, 1, # f8 - ff
64)
66HZ_ST = (
67MachineState.START, MachineState.ERROR, 3, MachineState.START, MachineState.START, MachineState.START, MachineState.ERROR, MachineState.ERROR, # 00-07
68MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, # 08-0f
69MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ERROR, MachineState.ERROR, MachineState.START, MachineState.START, 4, MachineState.ERROR, # 10-17
70 5, MachineState.ERROR, 6, MachineState.ERROR, 5, 5, 4, MachineState.ERROR, # 18-1f
71 4, MachineState.ERROR, 4, 4, 4, MachineState.ERROR, 4, MachineState.ERROR, # 20-27
72 4, MachineState.ITS_ME, MachineState.START, MachineState.START, MachineState.START, MachineState.START, MachineState.START, MachineState.START, # 28-2f
73)
74# fmt: on
76HZ_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0)
78HZ_SM_MODEL: CodingStateMachineDict = {
79 "class_table": HZ_CLS,
80 "class_factor": 6,
81 "state_table": HZ_ST,
82 "char_len_table": HZ_CHAR_LEN_TABLE,
83 "name": "HZ-GB-2312",
84 "language": "Chinese",
85}
87# fmt: off
88ISO2022CN_CLS = (
89 2, 0, 0, 0, 0, 0, 0, 0, # 00 - 07
90 0, 0, 0, 0, 0, 0, 0, 0, # 08 - 0f
91 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 17
92 0, 0, 0, 1, 0, 0, 0, 0, # 18 - 1f
93 0, 0, 0, 0, 0, 0, 0, 0, # 20 - 27
94 0, 3, 0, 0, 0, 0, 0, 0, # 28 - 2f
95 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 37
96 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f
97 0, 0, 0, 4, 0, 0, 0, 0, # 40 - 47
98 0, 0, 0, 0, 0, 0, 0, 0, # 48 - 4f
99 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 57
100 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f
101 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 67
102 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f
103 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 77
104 0, 0, 0, 0, 0, 0, 0, 0, # 78 - 7f
105 2, 2, 2, 2, 2, 2, 2, 2, # 80 - 87
106 2, 2, 2, 2, 2, 2, 2, 2, # 88 - 8f
107 2, 2, 2, 2, 2, 2, 2, 2, # 90 - 97
108 2, 2, 2, 2, 2, 2, 2, 2, # 98 - 9f
109 2, 2, 2, 2, 2, 2, 2, 2, # a0 - a7
110 2, 2, 2, 2, 2, 2, 2, 2, # a8 - af
111 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7
112 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf
113 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7
114 2, 2, 2, 2, 2, 2, 2, 2, # c8 - cf
115 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7
116 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df
117 2, 2, 2, 2, 2, 2, 2, 2, # e0 - e7
118 2, 2, 2, 2, 2, 2, 2, 2, # e8 - ef
119 2, 2, 2, 2, 2, 2, 2, 2, # f0 - f7
120 2, 2, 2, 2, 2, 2, 2, 2, # f8 - ff
121)
123ISO2022CN_ST = (
124 MachineState.START, 3, MachineState.ERROR, MachineState.START, MachineState.START, MachineState.START, MachineState.START, MachineState.START, # 00-07
125 MachineState.START, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, # 08-0f
126 MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, # 10-17
127 MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, 4, MachineState.ERROR, # 18-1f
128 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, # 20-27
129 5, 6, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, # 28-2f
130 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, # 30-37
131 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.ERROR, MachineState.START, # 38-3f
132)
133# fmt: on
135ISO2022CN_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0, 0, 0, 0)
137ISO2022CN_SM_MODEL: CodingStateMachineDict = {
138 "class_table": ISO2022CN_CLS,
139 "class_factor": 9,
140 "state_table": ISO2022CN_ST,
141 "char_len_table": ISO2022CN_CHAR_LEN_TABLE,
142 "name": "ISO-2022-CN",
143 "language": "Chinese",
144}
146# fmt: off
147ISO2022JP_CLS = (
148 2, 0, 0, 0, 0, 0, 0, 0, # 00 - 07
149 0, 0, 0, 0, 0, 0, 2, 2, # 08 - 0f
150 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 17
151 0, 0, 0, 1, 0, 0, 0, 0, # 18 - 1f
152 0, 0, 0, 0, 7, 0, 0, 0, # 20 - 27
153 3, 0, 0, 0, 0, 0, 0, 0, # 28 - 2f
154 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 37
155 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f
156 6, 0, 4, 0, 8, 0, 0, 0, # 40 - 47
157 0, 9, 5, 0, 0, 0, 0, 0, # 48 - 4f
158 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 57
159 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f
160 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 67
161 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f
162 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 77
163 0, 0, 0, 0, 0, 0, 0, 0, # 78 - 7f
164 2, 2, 2, 2, 2, 2, 2, 2, # 80 - 87
165 2, 2, 2, 2, 2, 2, 2, 2, # 88 - 8f
166 2, 2, 2, 2, 2, 2, 2, 2, # 90 - 97
167 2, 2, 2, 2, 2, 2, 2, 2, # 98 - 9f
168 2, 2, 2, 2, 2, 2, 2, 2, # a0 - a7
169 2, 2, 2, 2, 2, 2, 2, 2, # a8 - af
170 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7
171 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf
172 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7
173 2, 2, 2, 2, 2, 2, 2, 2, # c8 - cf
174 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7
175 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df
176 2, 2, 2, 2, 2, 2, 2, 2, # e0 - e7
177 2, 2, 2, 2, 2, 2, 2, 2, # e8 - ef
178 2, 2, 2, 2, 2, 2, 2, 2, # f0 - f7
179 2, 2, 2, 2, 2, 2, 2, 2, # f8 - ff
180)
182ISO2022JP_ST = (
183 MachineState.START, 3, MachineState.ERROR, MachineState.START, MachineState.START, MachineState.START, MachineState.START, MachineState.START, # 00-07
184 MachineState.START, MachineState.START, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, # 08-0f
185 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, # 10-17
186 MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ERROR, MachineState.ERROR, # 18-1f
187 MachineState.ERROR, 5, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, 4, MachineState.ERROR, MachineState.ERROR, # 20-27
188 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, 6, MachineState.ITS_ME, MachineState.ERROR, MachineState.ITS_ME, MachineState.ERROR, # 28-2f
189 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.ITS_ME, # 30-37
190 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, # 38-3f
191 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.ERROR, MachineState.START, MachineState.START, # 40-47
192)
193# fmt: on
195ISO2022JP_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
197ISO2022JP_SM_MODEL: CodingStateMachineDict = {
198 "class_table": ISO2022JP_CLS,
199 "class_factor": 10,
200 "state_table": ISO2022JP_ST,
201 "char_len_table": ISO2022JP_CHAR_LEN_TABLE,
202 "name": "ISO-2022-JP",
203 "language": "Japanese",
204}
206# fmt: off
207ISO2022KR_CLS = (
208 2, 0, 0, 0, 0, 0, 0, 0, # 00 - 07
209 0, 0, 0, 0, 0, 0, 0, 0, # 08 - 0f
210 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 17
211 0, 0, 0, 1, 0, 0, 0, 0, # 18 - 1f
212 0, 0, 0, 0, 3, 0, 0, 0, # 20 - 27
213 0, 4, 0, 0, 0, 0, 0, 0, # 28 - 2f
214 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 37
215 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f
216 0, 0, 0, 5, 0, 0, 0, 0, # 40 - 47
217 0, 0, 0, 0, 0, 0, 0, 0, # 48 - 4f
218 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 57
219 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f
220 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 67
221 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f
222 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 77
223 0, 0, 0, 0, 0, 0, 0, 0, # 78 - 7f
224 2, 2, 2, 2, 2, 2, 2, 2, # 80 - 87
225 2, 2, 2, 2, 2, 2, 2, 2, # 88 - 8f
226 2, 2, 2, 2, 2, 2, 2, 2, # 90 - 97
227 2, 2, 2, 2, 2, 2, 2, 2, # 98 - 9f
228 2, 2, 2, 2, 2, 2, 2, 2, # a0 - a7
229 2, 2, 2, 2, 2, 2, 2, 2, # a8 - af
230 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7
231 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf
232 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7
233 2, 2, 2, 2, 2, 2, 2, 2, # c8 - cf
234 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7
235 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df
236 2, 2, 2, 2, 2, 2, 2, 2, # e0 - e7
237 2, 2, 2, 2, 2, 2, 2, 2, # e8 - ef
238 2, 2, 2, 2, 2, 2, 2, 2, # f0 - f7
239 2, 2, 2, 2, 2, 2, 2, 2, # f8 - ff
240)
242ISO2022KR_ST = (
243 MachineState.START, 3, MachineState.ERROR, MachineState.START, MachineState.START, MachineState.START, MachineState.ERROR, MachineState.ERROR, # 00-07
244 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, # 08-0f
245 MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, 4, MachineState.ERROR, MachineState.ERROR, # 10-17
246 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, 5, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, # 18-1f
247 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.START, MachineState.START, MachineState.START, MachineState.START, # 20-27
248)
249# fmt: on
251ISO2022KR_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0)
253ISO2022KR_SM_MODEL: CodingStateMachineDict = {
254 "class_table": ISO2022KR_CLS,
255 "class_factor": 6,
256 "state_table": ISO2022KR_ST,
257 "char_len_table": ISO2022KR_CHAR_LEN_TABLE,
258 "name": "ISO-2022-KR",
259 "language": "Korean",
260}