1 | n/a | # |
---|
2 | n/a | # gb2312.py: Python Unicode Codec for GB2312 |
---|
3 | n/a | # |
---|
4 | n/a | # Written by Hye-Shik Chang <perky@FreeBSD.org> |
---|
5 | n/a | # |
---|
6 | n/a | |
---|
7 | n/a | import _codecs_cn, codecs |
---|
8 | n/a | import _multibytecodec as mbc |
---|
9 | n/a | |
---|
10 | n/a | codec = _codecs_cn.getcodec('gb2312') |
---|
11 | n/a | |
---|
12 | n/a | class Codec(codecs.Codec): |
---|
13 | n/a | encode = codec.encode |
---|
14 | n/a | decode = codec.decode |
---|
15 | n/a | |
---|
16 | n/a | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, |
---|
17 | n/a | codecs.IncrementalEncoder): |
---|
18 | n/a | codec = codec |
---|
19 | n/a | |
---|
20 | n/a | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, |
---|
21 | n/a | codecs.IncrementalDecoder): |
---|
22 | n/a | codec = codec |
---|
23 | n/a | |
---|
24 | n/a | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): |
---|
25 | n/a | codec = codec |
---|
26 | n/a | |
---|
27 | n/a | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): |
---|
28 | n/a | codec = codec |
---|
29 | n/a | |
---|
30 | n/a | def getregentry(): |
---|
31 | n/a | return codecs.CodecInfo( |
---|
32 | n/a | name='gb2312', |
---|
33 | n/a | encode=Codec().encode, |
---|
34 | n/a | decode=Codec().decode, |
---|
35 | n/a | incrementalencoder=IncrementalEncoder, |
---|
36 | n/a | incrementaldecoder=IncrementalDecoder, |
---|
37 | n/a | streamreader=StreamReader, |
---|
38 | n/a | streamwriter=StreamWriter, |
---|
39 | n/a | ) |
---|