Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d8407a7

Browse files
committed
Add new encoding for Ukrainian Cyrillic
1 parent 1e146e7 commit d8407a7

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

Lib/encodings/koi8_u.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
""" Python Character Mapping Codec for KOI8U.
2+
3+
This character scheme is compliant to RFC2319
4+
5+
Written by Marc-Andre Lemburg ([email protected]).
6+
Modified by Maxim Dzumanenko <[email protected]>.
7+
8+
(c) Copyright 2002, Python Software Foundation.
9+
10+
"""#"
11+
12+
import codecs, koi8_r
13+
14+
### Codec APIs
15+
16+
class Codec(codecs.Codec):
17+
18+
def encode(self,input,errors='strict'):
19+
20+
return codecs.charmap_encode(input,errors,encoding_map)
21+
22+
def decode(self,input,errors='strict'):
23+
24+
return codecs.charmap_decode(input,errors,decoding_map)
25+
26+
class StreamWriter(Codec,codecs.StreamWriter):
27+
pass
28+
29+
class StreamReader(Codec,codecs.StreamReader):
30+
pass
31+
32+
### encodings module API
33+
34+
def getregentry():
35+
36+
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
37+
38+
### Decoding Map
39+
40+
decoding_map = koi8_r.decoding_map.copy()
41+
decoding_map.update({
42+
0x00a4: 0x0454, # CYRILLIC SMALL LETTER UKRAINIAN IE
43+
0x00a6: 0x0456, # CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
44+
0x00a7: 0x0457, # CYRILLIC SMALL LETTER YI (UKRAINIAN)
45+
0x00ad: 0x0491, # CYRILLIC SMALL LETTER UKRAINIAN GHE WITH UPTURN
46+
0x00b4: 0x0403, # CYRILLIC CAPITAL LETTER UKRAINIAN IE
47+
0x00b6: 0x0406, # CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
48+
0x00b7: 0x0407, # CYRILLIC CAPITAL LETTER YI (UKRAINIAN)
49+
0x00bd: 0x0490, # CYRILLIC CAPITAL LETTER UKRAINIAN GHE WITH UPTURN
50+
})
51+
52+
### Encoding Map
53+
54+
encoding_map = codecs.make_encoding_map(decoding_map)

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ Robin Dunn
140140
Andy Dustman
141141
Gary Duzan
142142
Eugene Dvurechenski
143+
Maxim Dzumanenko
143144
Hans Eckardt
144145
Grant Edwards
145146
Lance Ellinghaus

0 commit comments

Comments
 (0)