Marc-André Lemburg | c759f07 | 2004-08-05 12:43:30 +0000 | [diff] [blame] | 1 | """ Python Character Mapping Codec for TIS-620. |
| 2 | |
| 3 | According to |
| 4 | ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-11.TXT the |
| 5 | TIS-620 is the identical to ISO_8859-11 with the 0xA0 (no-break |
| 6 | space) mapping removed. |
| 7 | |
| 8 | """#" |
| 9 | |
| 10 | import codecs |
| 11 | from encodings.iso8859_11 import decoding_map |
| 12 | |
| 13 | ### Codec APIs |
| 14 | |
| 15 | class Codec(codecs.Codec): |
| 16 | |
| 17 | def encode(self,input,errors='strict'): |
| 18 | |
| 19 | return codecs.charmap_encode(input,errors,encoding_map) |
| 20 | |
| 21 | def decode(self,input,errors='strict'): |
| 22 | |
| 23 | return codecs.charmap_decode(input,errors,decoding_map) |
| 24 | |
| 25 | class StreamWriter(Codec,codecs.StreamWriter): |
| 26 | pass |
| 27 | |
| 28 | class StreamReader(Codec,codecs.StreamReader): |
| 29 | pass |
| 30 | |
| 31 | ### encodings module API |
| 32 | |
| 33 | def getregentry(): |
| 34 | |
| 35 | return (Codec().encode,Codec().decode,StreamReader,StreamWriter) |
| 36 | |
| 37 | ### Decoding Map |
| 38 | |
| 39 | decoding_map = decoding_map.copy() |
| 40 | decoding_map.update({ |
Tim Peters | d1b7827 | 2004-08-07 06:03:09 +0000 | [diff] [blame] | 41 | 0x00a0: None, |
Marc-André Lemburg | c759f07 | 2004-08-05 12:43:30 +0000 | [diff] [blame] | 42 | }) |
| 43 | |
| 44 | ### Encoding Map |
| 45 | |
| 46 | encoding_map = codecs.make_encoding_map(decoding_map) |