Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 1 | # |
| 2 | # shift_jisx0213.py: Python Unicode Codec for SHIFT_JISX0213 |
| 3 | # |
| 4 | # Written by Hye-Shik Chang <perky@FreeBSD.org> |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 5 | # |
| 6 | |
Hye-Shik Chang | 2bb146f | 2004-07-18 03:06:29 +0000 | [diff] [blame] | 7 | import _codecs_jp, codecs |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 8 | import _multibytecodec as mbc |
Hye-Shik Chang | 2bb146f | 2004-07-18 03:06:29 +0000 | [diff] [blame] | 9 | |
| 10 | codec = _codecs_jp.getcodec('shift_jisx0213') |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 11 | |
| 12 | class Codec(codecs.Codec): |
| 13 | encode = codec.encode |
| 14 | decode = codec.decode |
| 15 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, |
| 17 | codecs.IncrementalEncoder): |
| 18 | codec = codec |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 19 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, |
| 21 | codecs.IncrementalDecoder): |
| 22 | codec = codec |
| 23 | |
| 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): |
| 25 | codec = codec |
| 26 | |
| 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): |
| 28 | codec = codec |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 29 | |
| 30 | def getregentry(): |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 31 | return codecs.CodecInfo( |
| 32 | name='shift_jisx0213', |
| 33 | encode=Codec().encode, |
| 34 | decode=Codec().decode, |
| 35 | incrementalencoder=IncrementalEncoder, |
| 36 | incrementaldecoder=IncrementalDecoder, |
| 37 | streamreader=StreamReader, |
| 38 | streamwriter=StreamWriter, |
| 39 | ) |