Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/chardet/escsm.py: 93%
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
88ISO2022JP_CLS = (
89 2, 0, 0, 0, 0, 0, 0, 0, # 00 - 07
90 0, 0, 0, 0, 0, 0, 2, 2, # 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, 7, 0, 0, 0, # 20 - 27
94 3, 0, 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 6, 0, 4, 0, 8, 0, 0, 0, # 40 - 47
98 0, 9, 5, 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)
123ISO2022JP_ST = (
124 MachineState.START, 3, MachineState.ERROR, MachineState.START, MachineState.START, MachineState.START, MachineState.START, MachineState.START, # 00-07
125 MachineState.START, MachineState.START, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, # 08-0f
126 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, 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.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ERROR, MachineState.ERROR, # 18-1f
128 MachineState.ERROR, 5, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, 4, MachineState.ERROR, MachineState.ERROR, # 20-27
129 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, 6, MachineState.ITS_ME, MachineState.ERROR, MachineState.ITS_ME, MachineState.ERROR, # 28-2f
130 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.ITS_ME, # 30-37
131 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, # 38-3f
132 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.ERROR, MachineState.START, MachineState.START, # 40-47
133)
134# fmt: on
136ISO2022JP_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
138ISO2022JP_SM_MODEL: CodingStateMachineDict = {
139 "class_table": ISO2022JP_CLS,
140 "class_factor": 10,
141 "state_table": ISO2022JP_ST,
142 "char_len_table": ISO2022JP_CHAR_LEN_TABLE,
143 "name": "ISO-2022-JP",
144 "language": "Japanese",
145}
147# fmt: off
148ISO2022KR_CLS = (
149 2, 0, 0, 0, 0, 0, 0, 0, # 00 - 07
150 0, 0, 0, 0, 0, 0, 0, 0, # 08 - 0f
151 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 17
152 0, 0, 0, 1, 0, 0, 0, 0, # 18 - 1f
153 0, 0, 0, 0, 3, 0, 0, 0, # 20 - 27
154 0, 4, 0, 0, 0, 0, 0, 0, # 28 - 2f
155 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 37
156 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f
157 0, 0, 0, 5, 0, 0, 0, 0, # 40 - 47
158 0, 0, 0, 0, 0, 0, 0, 0, # 48 - 4f
159 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 57
160 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f
161 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 67
162 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f
163 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 77
164 0, 0, 0, 0, 0, 0, 0, 0, # 78 - 7f
165 2, 2, 2, 2, 2, 2, 2, 2, # 80 - 87
166 2, 2, 2, 2, 2, 2, 2, 2, # 88 - 8f
167 2, 2, 2, 2, 2, 2, 2, 2, # 90 - 97
168 2, 2, 2, 2, 2, 2, 2, 2, # 98 - 9f
169 2, 2, 2, 2, 2, 2, 2, 2, # a0 - a7
170 2, 2, 2, 2, 2, 2, 2, 2, # a8 - af
171 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7
172 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf
173 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7
174 2, 2, 2, 2, 2, 2, 2, 2, # c8 - cf
175 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7
176 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df
177 2, 2, 2, 2, 2, 2, 2, 2, # e0 - e7
178 2, 2, 2, 2, 2, 2, 2, 2, # e8 - ef
179 2, 2, 2, 2, 2, 2, 2, 2, # f0 - f7
180 2, 2, 2, 2, 2, 2, 2, 2, # f8 - ff
181)
183ISO2022KR_ST = (
184 MachineState.START, 3, MachineState.ERROR, MachineState.START, MachineState.START, MachineState.START, MachineState.ERROR, MachineState.ERROR, # 00-07
185 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ITS_ME, # 08-0f
186 MachineState.ITS_ME, MachineState.ITS_ME, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, 4, MachineState.ERROR, MachineState.ERROR, # 10-17
187 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, 5, MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, # 18-1f
188 MachineState.ERROR, MachineState.ERROR, MachineState.ERROR, MachineState.ITS_ME, MachineState.START, MachineState.START, MachineState.START, MachineState.START, # 20-27
189)
190# fmt: on
192ISO2022KR_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0)
194ISO2022KR_SM_MODEL: CodingStateMachineDict = {
195 "class_table": ISO2022KR_CLS,
196 "class_factor": 6,
197 "state_table": ISO2022KR_ST,
198 "char_len_table": ISO2022KR_CHAR_LEN_TABLE,
199 "name": "ISO-2022-KR",
200 "language": "Korean",
201}