| Marc-André Lemburg | a83ffa8 | 2002-07-12 14:36:22 +0000 | [diff] [blame] | 1 | """ Python Character Mapping Codec for PalmOS 3.5. | 
 | 2 |  | 
 | 3 | Written by Sjoerd Mullender (sjoerd@acm.org); based on iso8859_15.py. | 
 | 4 |  | 
 | 5 | """#" | 
 | 6 |  | 
 | 7 | import codecs | 
 | 8 |  | 
 | 9 | ### Codec APIs | 
 | 10 |  | 
 | 11 | class Codec(codecs.Codec): | 
 | 12 |     def encode(self,input,errors='strict'): | 
 | 13 |         return codecs.charmap_encode(input,errors,encoding_map) | 
| Tim Peters | 469cdad | 2002-08-08 20:19:19 +0000 | [diff] [blame] | 14 |  | 
| Marc-André Lemburg | a83ffa8 | 2002-07-12 14:36:22 +0000 | [diff] [blame] | 15 |     def decode(self,input,errors='strict'): | 
 | 16 |         return codecs.charmap_decode(input,errors,decoding_map) | 
 | 17 |  | 
 | 18 | class StreamWriter(Codec,codecs.StreamWriter): | 
 | 19 |     pass | 
| Tim Peters | 469cdad | 2002-08-08 20:19:19 +0000 | [diff] [blame] | 20 |  | 
| Marc-André Lemburg | a83ffa8 | 2002-07-12 14:36:22 +0000 | [diff] [blame] | 21 | class StreamReader(Codec,codecs.StreamReader): | 
 | 22 |     pass | 
 | 23 |  | 
 | 24 | ### encodings module API | 
 | 25 |  | 
 | 26 | def getregentry(): | 
 | 27 |     return (Codec().encode,Codec().decode,StreamReader,StreamWriter) | 
 | 28 |  | 
 | 29 | ### Decoding Map | 
 | 30 |  | 
 | 31 | decoding_map = codecs.make_identity_dict(range(256)) | 
 | 32 |  | 
 | 33 | # The PalmOS character set is mostly iso-8859-1 with some differences. | 
 | 34 | decoding_map.update({ | 
 | 35 |         0x0080: 0x20ac, #       EURO SIGN | 
 | 36 |         0x0082: 0x201a, #       SINGLE LOW-9 QUOTATION MARK | 
 | 37 |         0x0083: 0x0192, #       LATIN SMALL LETTER F WITH HOOK | 
 | 38 |         0x0084: 0x201e, #       DOUBLE LOW-9 QUOTATION MARK | 
 | 39 |         0x0085: 0x2026, #       HORIZONTAL ELLIPSIS | 
 | 40 |         0x0086: 0x2020, #       DAGGER | 
 | 41 |         0x0087: 0x2021, #       DOUBLE DAGGER | 
 | 42 |         0x0088: 0x02c6, #       MODIFIER LETTER CIRCUMFLEX ACCENT | 
 | 43 |         0x0089: 0x2030, #       PER MILLE SIGN | 
 | 44 |         0x008a: 0x0160, #       LATIN CAPITAL LETTER S WITH CARON | 
 | 45 |         0x008b: 0x2039, #       SINGLE LEFT-POINTING ANGLE QUOTATION MARK | 
 | 46 |         0x008c: 0x0152, #       LATIN CAPITAL LIGATURE OE | 
 | 47 |         0x008d: 0x2666, #       BLACK DIAMOND SUIT | 
 | 48 |         0x008e: 0x2663, #       BLACK CLUB SUIT | 
 | 49 |         0x008f: 0x2665, #       BLACK HEART SUIT | 
 | 50 |         0x0090: 0x2660, #       BLACK SPADE SUIT | 
 | 51 |         0x0091: 0x2018, #       LEFT SINGLE QUOTATION MARK | 
 | 52 |         0x0092: 0x2019, #       RIGHT SINGLE QUOTATION MARK | 
 | 53 |         0x0093: 0x201c, #       LEFT DOUBLE QUOTATION MARK | 
 | 54 |         0x0094: 0x201d, #       RIGHT DOUBLE QUOTATION MARK | 
 | 55 |         0x0095: 0x2022, #       BULLET | 
 | 56 |         0x0096: 0x2013, #       EN DASH | 
 | 57 |         0x0097: 0x2014, #       EM DASH | 
 | 58 |         0x0098: 0x02dc, #       SMALL TILDE | 
 | 59 |         0x0099: 0x2122, #       TRADE MARK SIGN | 
 | 60 |         0x009a: 0x0161, #       LATIN SMALL LETTER S WITH CARON | 
 | 61 |         0x009c: 0x0153, #       LATIN SMALL LIGATURE OE | 
 | 62 |         0x009f: 0x0178, #       LATIN CAPITAL LETTER Y WITH DIAERESIS | 
 | 63 | }) | 
 | 64 |  | 
 | 65 | ### Encoding Map | 
 | 66 |  | 
 | 67 | encoding_map = codecs.make_encoding_map(decoding_map) |