character-encoding-utils 0.0.12__tar.gz → 0.0.13__tar.gz
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.
- character_encoding_utils-0.0.13/LICENSE +21 -0
- {character_encoding_utils-0.0.12 → character_encoding_utils-0.0.13}/PKG-INFO +6 -5
- {character_encoding_utils-0.0.12 → character_encoding_utils-0.0.13}/README.md +2 -2
- character_encoding_utils-0.0.13/pyproject.toml +46 -0
- character_encoding_utils-0.0.12/pyproject.toml → character_encoding_utils-0.0.13/pyproject.toml.orig +13 -7
- {character_encoding_utils-0.0.12 → character_encoding_utils-0.0.13}/src/character_encoding_utils/big5.py +15 -15
- {character_encoding_utils-0.0.12 → character_encoding_utils-0.0.13}/src/character_encoding_utils/gb2312.py +15 -15
- {character_encoding_utils-0.0.12 → character_encoding_utils-0.0.13}/src/character_encoding_utils/ksx1001.py +18 -18
- {character_encoding_utils-0.0.12 → character_encoding_utils-0.0.13}/src/character_encoding_utils/shiftjis.py +21 -21
- {character_encoding_utils-0.0.12 → character_encoding_utils-0.0.13}/src/character_encoding_utils/__init__.py +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 TakWolf
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: character-encoding-utils
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.13
|
|
4
4
|
Summary: Some character encoding utils
|
|
5
5
|
Keywords: encoding,gb2312,big5,shift-jis,ksx1001
|
|
6
6
|
Author: TakWolf
|
|
7
7
|
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
8
9
|
Classifier: Programming Language :: Python :: 3
|
|
9
10
|
Classifier: Programming Language :: Python :: 3.10
|
|
10
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
11
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
12
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
13
14
|
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
-
Classifier:
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
15
16
|
Classifier: Operating System :: OS Independent
|
|
16
17
|
Maintainer: TakWolf
|
|
17
18
|
Requires-Python: >=3.10
|
|
18
19
|
Project-URL: Homepage, https://github.com/TakWolf/character-encoding-utils
|
|
19
|
-
Project-URL: Issues, https://github.com/TakWolf/character-encoding-utils/issues
|
|
20
20
|
Project-URL: Source, https://github.com/TakWolf/character-encoding-utils
|
|
21
|
+
Project-URL: Issues, https://github.com/TakWolf/character-encoding-utils/issues
|
|
21
22
|
Description-Content-Type: text/markdown
|
|
22
23
|
|
|
23
24
|
# Character Encoding Utils
|
|
24
25
|
|
|
25
|
-
[](https://www.python.org)
|
|
26
|
-
[](https://pypi.org/project/character-encoding-utils/)
|
|
26
|
+
[](https://www.python.org)
|
|
27
|
+
[](https://pypi.org/project/character-encoding-utils/)
|
|
27
28
|
|
|
28
29
|
Some [character encoding](https://en.wikipedia.org/wiki/Character_encoding) utils.
|
|
29
30
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Character Encoding Utils
|
|
2
2
|
|
|
3
|
-
[](https://www.python.org)
|
|
4
|
-
[](https://pypi.org/project/character-encoding-utils/)
|
|
3
|
+
[](https://www.python.org)
|
|
4
|
+
[](https://pypi.org/project/character-encoding-utils/)
|
|
5
5
|
|
|
6
6
|
Some [character encoding](https://en.wikipedia.org/wiki/Character_encoding) utils.
|
|
7
7
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "character-encoding-utils"
|
|
3
|
+
version = "0.0.13"
|
|
4
|
+
description = "Some character encoding utils"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
keywords = [
|
|
9
|
+
"encoding",
|
|
10
|
+
"gb2312",
|
|
11
|
+
"big5",
|
|
12
|
+
"shift-jis",
|
|
13
|
+
"ksx1001",
|
|
14
|
+
]
|
|
15
|
+
requires-python = ">=3.10"
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: Python :: 3.14",
|
|
23
|
+
"Programming Language :: Python :: 3.15",
|
|
24
|
+
"Operating System :: OS Independent",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[[project.authors]]
|
|
28
|
+
name = "TakWolf"
|
|
29
|
+
|
|
30
|
+
[[project.maintainers]]
|
|
31
|
+
name = "TakWolf"
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/TakWolf/character-encoding-utils"
|
|
35
|
+
Source = "https://github.com/TakWolf/character-encoding-utils"
|
|
36
|
+
Issues = "https://github.com/TakWolf/character-encoding-utils/issues"
|
|
37
|
+
|
|
38
|
+
[dependency-groups]
|
|
39
|
+
dev = ["pytest>=9.1.1"]
|
|
40
|
+
|
|
41
|
+
[build-system]
|
|
42
|
+
requires = ["uv_build"]
|
|
43
|
+
build-backend = "uv_build"
|
|
44
|
+
|
|
45
|
+
[tool.pytest.ini_options]
|
|
46
|
+
addopts = ["--import-mode=importlib"]
|
character_encoding_utils-0.0.12/pyproject.toml → character_encoding_utils-0.0.13/pyproject.toml.orig
RENAMED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["uv_build"]
|
|
3
|
-
build-backend = "uv_build"
|
|
4
|
-
|
|
5
1
|
[project]
|
|
6
2
|
name = "character-encoding-utils"
|
|
7
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.13"
|
|
8
4
|
description = "Some character encoding utils"
|
|
9
5
|
readme = "README.md"
|
|
10
6
|
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
11
8
|
authors = [
|
|
12
9
|
{ name = "TakWolf" },
|
|
13
10
|
]
|
|
@@ -23,16 +20,25 @@ classifiers = [
|
|
|
23
20
|
"Programming Language :: Python :: 3.12",
|
|
24
21
|
"Programming Language :: Python :: 3.13",
|
|
25
22
|
"Programming Language :: Python :: 3.14",
|
|
26
|
-
"
|
|
23
|
+
"Programming Language :: Python :: 3.15",
|
|
27
24
|
"Operating System :: OS Independent",
|
|
28
25
|
]
|
|
29
26
|
|
|
30
27
|
[dependency-groups]
|
|
31
28
|
dev = [
|
|
32
|
-
"pytest>=9.
|
|
29
|
+
"pytest>=9.1.1",
|
|
33
30
|
]
|
|
34
31
|
|
|
35
32
|
[project.urls]
|
|
36
33
|
Homepage = "https://github.com/TakWolf/character-encoding-utils"
|
|
37
34
|
Source = "https://github.com/TakWolf/character-encoding-utils"
|
|
38
35
|
Issues = "https://github.com/TakWolf/character-encoding-utils/issues"
|
|
36
|
+
|
|
37
|
+
[build-system]
|
|
38
|
+
requires = ["uv_build"]
|
|
39
|
+
build-backend = "uv_build"
|
|
40
|
+
|
|
41
|
+
[tool.pytest.ini_options]
|
|
42
|
+
addopts = [
|
|
43
|
+
"--import-mode=importlib",
|
|
44
|
+
]
|
|
@@ -8,7 +8,7 @@ class Big5EncodeError(Big5Exception):
|
|
|
8
8
|
position: int
|
|
9
9
|
reason: str
|
|
10
10
|
|
|
11
|
-
def __init__(self, obj: str, position: int, reason: str):
|
|
11
|
+
def __init__(self, obj: str, position: int, reason: str) -> None:
|
|
12
12
|
self.obj = obj
|
|
13
13
|
self.position = position
|
|
14
14
|
self.reason = reason
|
|
@@ -22,7 +22,7 @@ class Big5DecodeError(Big5Exception):
|
|
|
22
22
|
position: int
|
|
23
23
|
reason: str
|
|
24
24
|
|
|
25
|
-
def __init__(self, obj: bytes, position: int, reason: str):
|
|
25
|
+
def __init__(self, obj: bytes, position: int, reason: str) -> None:
|
|
26
26
|
self.obj = obj
|
|
27
27
|
self.position = position
|
|
28
28
|
self.reason = reason
|
|
@@ -112,7 +112,7 @@ def decode(bs: bytes | bytearray) -> str:
|
|
|
112
112
|
|
|
113
113
|
def query_code(c: str) -> int:
|
|
114
114
|
if len(c) != 1:
|
|
115
|
-
raise Big5Exception('
|
|
115
|
+
raise Big5Exception('must be one character')
|
|
116
116
|
try:
|
|
117
117
|
bs = encode(c)
|
|
118
118
|
except Big5EncodeError as e:
|
|
@@ -160,39 +160,39 @@ def _build_alphabet_by_codes_between(code_start: int, code_end: int) -> list[str
|
|
|
160
160
|
return alphabet
|
|
161
161
|
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
_ALPHABET_OTHER = _build_alphabet_by_codes_between(0xA140, 0xA3BF)
|
|
164
|
+
_ALPHABET_LEVEL_1 = _build_alphabet_by_codes_between(0xA440, 0xC67E)
|
|
165
|
+
_ALPHABET_LEVEL_2 = _build_alphabet_by_codes_between(0xC940, 0xF9D5)
|
|
166
|
+
_ALPHABET = _ALPHABET_OTHER + _ALPHABET_LEVEL_1 + _ALPHABET_LEVEL_2
|
|
167
167
|
|
|
168
168
|
|
|
169
169
|
def get_alphabet_other() -> list[str]:
|
|
170
|
-
return
|
|
170
|
+
return _ALPHABET_OTHER.copy()
|
|
171
171
|
|
|
172
172
|
|
|
173
173
|
def get_alphabet_level_1() -> list[str]:
|
|
174
|
-
return
|
|
174
|
+
return _ALPHABET_LEVEL_1.copy()
|
|
175
175
|
|
|
176
176
|
|
|
177
177
|
def get_alphabet_level_2() -> list[str]:
|
|
178
|
-
return
|
|
178
|
+
return _ALPHABET_LEVEL_2.copy()
|
|
179
179
|
|
|
180
180
|
|
|
181
181
|
def get_alphabet() -> list[str]:
|
|
182
|
-
return
|
|
182
|
+
return _ALPHABET.copy()
|
|
183
183
|
|
|
184
184
|
|
|
185
185
|
def get_other_count() -> int:
|
|
186
|
-
return len(
|
|
186
|
+
return len(_ALPHABET_OTHER)
|
|
187
187
|
|
|
188
188
|
|
|
189
189
|
def get_level_1_count() -> int:
|
|
190
|
-
return len(
|
|
190
|
+
return len(_ALPHABET_LEVEL_1)
|
|
191
191
|
|
|
192
192
|
|
|
193
193
|
def get_level_2_count() -> int:
|
|
194
|
-
return len(
|
|
194
|
+
return len(_ALPHABET_LEVEL_2)
|
|
195
195
|
|
|
196
196
|
|
|
197
197
|
def get_count() -> int:
|
|
198
|
-
return len(
|
|
198
|
+
return len(_ALPHABET)
|
|
@@ -11,7 +11,7 @@ class GB2312EncodeError(GB2312Exception):
|
|
|
11
11
|
position: int
|
|
12
12
|
reason: str
|
|
13
13
|
|
|
14
|
-
def __init__(self, obj: str, position: int, reason: str):
|
|
14
|
+
def __init__(self, obj: str, position: int, reason: str) -> None:
|
|
15
15
|
self.obj = obj
|
|
16
16
|
self.position = position
|
|
17
17
|
self.reason = reason
|
|
@@ -25,7 +25,7 @@ class GB2312DecodeError(GB2312Exception):
|
|
|
25
25
|
position: int
|
|
26
26
|
reason: str
|
|
27
27
|
|
|
28
|
-
def __init__(self, obj: bytes, position: int, reason: str):
|
|
28
|
+
def __init__(self, obj: bytes, position: int, reason: str) -> None:
|
|
29
29
|
self.obj = obj
|
|
30
30
|
self.position = position
|
|
31
31
|
self.reason = reason
|
|
@@ -72,7 +72,7 @@ def decode(bs: bytes | bytearray) -> str:
|
|
|
72
72
|
|
|
73
73
|
def query_coord(c: str) -> tuple[int, int]:
|
|
74
74
|
if len(c) != 1:
|
|
75
|
-
raise GB2312Exception('
|
|
75
|
+
raise GB2312Exception('must be one character')
|
|
76
76
|
try:
|
|
77
77
|
bs = encode(c)
|
|
78
78
|
except GB2312EncodeError as e:
|
|
@@ -124,39 +124,39 @@ def _build_alphabet_by_rows_between(row_start: int, row_end: int) -> list[str]:
|
|
|
124
124
|
return alphabet
|
|
125
125
|
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
_ALPHABET_OTHER = _build_alphabet_by_rows_between(1, 9)
|
|
128
|
+
_ALPHABET_LEVEL_1 = _build_alphabet_by_rows_between(16, 55)
|
|
129
|
+
_ALPHABET_LEVEL_2 = _build_alphabet_by_rows_between(56, 87)
|
|
130
|
+
_ALPHABET = _ALPHABET_OTHER + _ALPHABET_LEVEL_1 + _ALPHABET_LEVEL_2
|
|
131
131
|
|
|
132
132
|
|
|
133
133
|
def get_alphabet_other() -> list[str]:
|
|
134
|
-
return
|
|
134
|
+
return _ALPHABET_OTHER.copy()
|
|
135
135
|
|
|
136
136
|
|
|
137
137
|
def get_alphabet_level_1() -> list[str]:
|
|
138
|
-
return
|
|
138
|
+
return _ALPHABET_LEVEL_1.copy()
|
|
139
139
|
|
|
140
140
|
|
|
141
141
|
def get_alphabet_level_2() -> list[str]:
|
|
142
|
-
return
|
|
142
|
+
return _ALPHABET_LEVEL_2.copy()
|
|
143
143
|
|
|
144
144
|
|
|
145
145
|
def get_alphabet() -> list[str]:
|
|
146
|
-
return
|
|
146
|
+
return _ALPHABET.copy()
|
|
147
147
|
|
|
148
148
|
|
|
149
149
|
def get_other_count() -> int:
|
|
150
|
-
return len(
|
|
150
|
+
return len(_ALPHABET_OTHER)
|
|
151
151
|
|
|
152
152
|
|
|
153
153
|
def get_level_1_count() -> int:
|
|
154
|
-
return len(
|
|
154
|
+
return len(_ALPHABET_LEVEL_1)
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
def get_level_2_count() -> int:
|
|
158
|
-
return len(
|
|
158
|
+
return len(_ALPHABET_LEVEL_2)
|
|
159
159
|
|
|
160
160
|
|
|
161
161
|
def get_count() -> int:
|
|
162
|
-
return len(
|
|
162
|
+
return len(_ALPHABET)
|
|
@@ -11,7 +11,7 @@ class KSX1001EncodeError(KSX1001Exception):
|
|
|
11
11
|
position: int
|
|
12
12
|
reason: str
|
|
13
13
|
|
|
14
|
-
def __init__(self, obj: str, position: int, reason: str):
|
|
14
|
+
def __init__(self, obj: str, position: int, reason: str) -> None:
|
|
15
15
|
self.obj = obj
|
|
16
16
|
self.position = position
|
|
17
17
|
self.reason = reason
|
|
@@ -25,7 +25,7 @@ class KSX1001DecodeError(KSX1001Exception):
|
|
|
25
25
|
position: int
|
|
26
26
|
reason: str
|
|
27
27
|
|
|
28
|
-
def __init__(self, obj: bytes, position: int, reason: str):
|
|
28
|
+
def __init__(self, obj: bytes, position: int, reason: str) -> None:
|
|
29
29
|
self.obj = obj
|
|
30
30
|
self.position = position
|
|
31
31
|
self.reason = reason
|
|
@@ -41,7 +41,7 @@ def encode(cs: str) -> bytes:
|
|
|
41
41
|
bs = bytearray()
|
|
42
42
|
for position, c in enumerate(cs):
|
|
43
43
|
try:
|
|
44
|
-
bs.extend(c.encode('
|
|
44
|
+
bs.extend(c.encode('euc_kr'))
|
|
45
45
|
except UnicodeEncodeError as e:
|
|
46
46
|
raise KSX1001EncodeError(c, position, e.reason) from e
|
|
47
47
|
return bytes(bs)
|
|
@@ -77,7 +77,7 @@ def decode(bs: bytes | bytearray) -> str:
|
|
|
77
77
|
cs.append(chr(0x3164)) # Hangul Filler
|
|
78
78
|
else:
|
|
79
79
|
try:
|
|
80
|
-
cs.append(bc.decode('
|
|
80
|
+
cs.append(bc.decode('euc_kr'))
|
|
81
81
|
except UnicodeDecodeError as e:
|
|
82
82
|
raise KSX1001DecodeError(bc, passed, e.reason) from e
|
|
83
83
|
passed += len(bc)
|
|
@@ -86,7 +86,7 @@ def decode(bs: bytes | bytearray) -> str:
|
|
|
86
86
|
|
|
87
87
|
def query_coord(c: str) -> tuple[int, int]:
|
|
88
88
|
if len(c) != 1:
|
|
89
|
-
raise KSX1001Exception('
|
|
89
|
+
raise KSX1001Exception('must be one character')
|
|
90
90
|
try:
|
|
91
91
|
bs = encode(c)
|
|
92
92
|
except KSX1001EncodeError as e:
|
|
@@ -100,7 +100,7 @@ def query_coord(c: str) -> tuple[int, int]:
|
|
|
100
100
|
return row, col
|
|
101
101
|
|
|
102
102
|
|
|
103
|
-
def query_chr(row: int, col: int):
|
|
103
|
+
def query_chr(row: int, col: int) -> str:
|
|
104
104
|
if row < 1 or row > 94 or col < 1 or col > 94:
|
|
105
105
|
raise KSX1001Exception(f"'row' and 'col' must between 1 and 94")
|
|
106
106
|
try:
|
|
@@ -140,39 +140,39 @@ def _build_alphabet_by_rows_between(row_start: int, row_end: int) -> list[str]:
|
|
|
140
140
|
return alphabet
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
_ALPHABET_OTHER = _build_alphabet_by_rows_between(1, 12)
|
|
144
|
+
_ALPHABET_SYLLABLE = _build_alphabet_by_rows_between(16, 40)
|
|
145
|
+
_ALPHABET_HANJA = _build_alphabet_by_rows_between(42, 93)
|
|
146
|
+
_ALPHABET = _ALPHABET_OTHER + _ALPHABET_SYLLABLE + _ALPHABET_HANJA
|
|
147
147
|
|
|
148
148
|
|
|
149
149
|
def get_alphabet_other() -> list[str]:
|
|
150
|
-
return
|
|
150
|
+
return _ALPHABET_OTHER.copy()
|
|
151
151
|
|
|
152
152
|
|
|
153
153
|
def get_alphabet_syllable() -> list[str]:
|
|
154
|
-
return
|
|
154
|
+
return _ALPHABET_SYLLABLE.copy()
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
def get_alphabet_hanja() -> list[str]:
|
|
158
|
-
return
|
|
158
|
+
return _ALPHABET_HANJA.copy()
|
|
159
159
|
|
|
160
160
|
|
|
161
161
|
def get_alphabet() -> list[str]:
|
|
162
|
-
return
|
|
162
|
+
return _ALPHABET.copy()
|
|
163
163
|
|
|
164
164
|
|
|
165
165
|
def get_other_count() -> int:
|
|
166
|
-
return len(
|
|
166
|
+
return len(_ALPHABET_OTHER)
|
|
167
167
|
|
|
168
168
|
|
|
169
169
|
def get_syllable_count() -> int:
|
|
170
|
-
return len(
|
|
170
|
+
return len(_ALPHABET_SYLLABLE)
|
|
171
171
|
|
|
172
172
|
|
|
173
173
|
def get_hanja_count() -> int:
|
|
174
|
-
return len(
|
|
174
|
+
return len(_ALPHABET_HANJA)
|
|
175
175
|
|
|
176
176
|
|
|
177
177
|
def get_count() -> int:
|
|
178
|
-
return len(
|
|
178
|
+
return len(_ALPHABET)
|
|
@@ -10,7 +10,7 @@ class ShiftJISEncodeError(ShiftJISException):
|
|
|
10
10
|
position: int
|
|
11
11
|
reason: str
|
|
12
12
|
|
|
13
|
-
def __init__(self, obj: str, position: int, reason: str):
|
|
13
|
+
def __init__(self, obj: str, position: int, reason: str) -> None:
|
|
14
14
|
self.obj = obj
|
|
15
15
|
self.position = position
|
|
16
16
|
self.reason = reason
|
|
@@ -24,7 +24,7 @@ class ShiftJISDecodeError(ShiftJISException):
|
|
|
24
24
|
position: int
|
|
25
25
|
reason: str
|
|
26
26
|
|
|
27
|
-
def __init__(self, obj: bytes, position: int, reason: str):
|
|
27
|
+
def __init__(self, obj: bytes, position: int, reason: str) -> None:
|
|
28
28
|
self.obj = obj
|
|
29
29
|
self.position = position
|
|
30
30
|
self.reason = reason
|
|
@@ -172,58 +172,58 @@ def _build_alphabet_double_byte_kanji() -> list[str]:
|
|
|
172
172
|
return alphabet
|
|
173
173
|
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
175
|
+
_ALPHABET_SINGLE_BYTE_ASCII_CONTROL = _build_alphabet_single_byte(0x00, 0x1F)
|
|
176
|
+
_ALPHABET_SINGLE_BYTE_ASCII_CONTROL.append(chr(0x7F))
|
|
177
|
+
_ALPHABET_SINGLE_BYTE_ASCII_PRINTABLE = _build_alphabet_single_byte(0x20, 0x7E)
|
|
178
|
+
_ALPHABET_SINGLE_BYTE_HALF_WIDTH_KATAKANA = _build_alphabet_single_byte(0xA1, 0xDF)
|
|
179
|
+
_ALPHABET_DOUBLE_BYTE_OTHER = _build_alphabet_double_byte_other()
|
|
180
|
+
_ALPHABET_DOUBLE_BYTE_KANJI = _build_alphabet_double_byte_kanji()
|
|
181
|
+
_ALPHABET = _ALPHABET_SINGLE_BYTE_ASCII_CONTROL + _ALPHABET_SINGLE_BYTE_ASCII_PRINTABLE + _ALPHABET_SINGLE_BYTE_HALF_WIDTH_KATAKANA + _ALPHABET_DOUBLE_BYTE_OTHER + _ALPHABET_DOUBLE_BYTE_KANJI
|
|
182
182
|
|
|
183
183
|
|
|
184
184
|
def get_alphabet_single_byte_ascii_control() -> list[str]:
|
|
185
|
-
return
|
|
185
|
+
return _ALPHABET_SINGLE_BYTE_ASCII_CONTROL.copy()
|
|
186
186
|
|
|
187
187
|
|
|
188
188
|
def get_alphabet_single_byte_ascii_printable() -> list[str]:
|
|
189
|
-
return
|
|
189
|
+
return _ALPHABET_SINGLE_BYTE_ASCII_PRINTABLE.copy()
|
|
190
190
|
|
|
191
191
|
|
|
192
192
|
def get_alphabet_single_byte_half_width_katakana() -> list[str]:
|
|
193
|
-
return
|
|
193
|
+
return _ALPHABET_SINGLE_BYTE_HALF_WIDTH_KATAKANA.copy()
|
|
194
194
|
|
|
195
195
|
|
|
196
196
|
def get_alphabet_double_byte_other() -> list[str]:
|
|
197
|
-
return
|
|
197
|
+
return _ALPHABET_DOUBLE_BYTE_OTHER.copy()
|
|
198
198
|
|
|
199
199
|
|
|
200
200
|
def get_alphabet_double_byte_kanji() -> list[str]:
|
|
201
|
-
return
|
|
201
|
+
return _ALPHABET_DOUBLE_BYTE_KANJI.copy()
|
|
202
202
|
|
|
203
203
|
|
|
204
204
|
def get_alphabet() -> list[str]:
|
|
205
|
-
return
|
|
205
|
+
return _ALPHABET.copy()
|
|
206
206
|
|
|
207
207
|
|
|
208
208
|
def get_single_byte_ascii_control_count() -> int:
|
|
209
|
-
return len(
|
|
209
|
+
return len(_ALPHABET_SINGLE_BYTE_ASCII_CONTROL)
|
|
210
210
|
|
|
211
211
|
|
|
212
212
|
def get_single_byte_ascii_printable_count() -> int:
|
|
213
|
-
return len(
|
|
213
|
+
return len(_ALPHABET_SINGLE_BYTE_ASCII_PRINTABLE)
|
|
214
214
|
|
|
215
215
|
|
|
216
216
|
def get_single_byte_half_width_katakana_count() -> int:
|
|
217
|
-
return len(
|
|
217
|
+
return len(_ALPHABET_SINGLE_BYTE_HALF_WIDTH_KATAKANA)
|
|
218
218
|
|
|
219
219
|
|
|
220
220
|
def get_double_byte_other_count() -> int:
|
|
221
|
-
return len(
|
|
221
|
+
return len(_ALPHABET_DOUBLE_BYTE_OTHER)
|
|
222
222
|
|
|
223
223
|
|
|
224
224
|
def get_double_byte_kanji_count() -> int:
|
|
225
|
-
return len(
|
|
225
|
+
return len(_ALPHABET_DOUBLE_BYTE_KANJI)
|
|
226
226
|
|
|
227
227
|
|
|
228
228
|
def get_count() -> int:
|
|
229
|
-
return len(
|
|
229
|
+
return len(_ALPHABET)
|
|
File without changes
|