Marc-André Lemburg | a866df8 | 2001-01-03 21:29:14 +0000 | [diff] [blame] | 1 | """ Python Character Mapping Codec generated from 'CP1256.TXT' with gencodec.py. |
Guido van Rossum | 0229bf6 | 2000-03-10 23:17:24 +0000 | [diff] [blame] | 2 | |
| 3 | Written by Marc-Andre Lemburg (mal@lemburg.com). |
| 4 | |
| 5 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. |
Marc-André Lemburg | a866df8 | 2001-01-03 21:29:14 +0000 | [diff] [blame] | 6 | (c) Copyright 2000 Guido van Rossum. |
Guido van Rossum | 0229bf6 | 2000-03-10 23:17:24 +0000 | [diff] [blame] | 7 | |
| 8 | """#" |
| 9 | |
| 10 | import codecs |
| 11 | |
| 12 | ### Codec APIs |
| 13 | |
| 14 | class Codec(codecs.Codec): |
| 15 | |
| 16 | def encode(self,input,errors='strict'): |
| 17 | |
| 18 | return codecs.charmap_encode(input,errors,encoding_map) |
| 19 | |
| 20 | def decode(self,input,errors='strict'): |
| 21 | |
| 22 | return codecs.charmap_decode(input,errors,decoding_map) |
| 23 | |
| 24 | class StreamWriter(Codec,codecs.StreamWriter): |
| 25 | pass |
| 26 | |
| 27 | class StreamReader(Codec,codecs.StreamReader): |
| 28 | pass |
| 29 | |
| 30 | ### encodings module API |
| 31 | |
| 32 | def getregentry(): |
| 33 | |
| 34 | return (Codec().encode,Codec().decode,StreamReader,StreamWriter) |
| 35 | |
| 36 | ### Decoding Map |
| 37 | |
Marc-André Lemburg | a866df8 | 2001-01-03 21:29:14 +0000 | [diff] [blame] | 38 | decoding_map = codecs.make_identity_dict(range(256)) |
| 39 | decoding_map.update({ |
Guido van Rossum | 0229bf6 | 2000-03-10 23:17:24 +0000 | [diff] [blame] | 40 | 0x0080: 0x20ac, # EURO SIGN |
| 41 | 0x0081: 0x067e, # ARABIC LETTER PEH |
| 42 | 0x0082: 0x201a, # SINGLE LOW-9 QUOTATION MARK |
| 43 | 0x0083: 0x0192, # LATIN SMALL LETTER F WITH HOOK |
| 44 | 0x0084: 0x201e, # DOUBLE LOW-9 QUOTATION MARK |
| 45 | 0x0085: 0x2026, # HORIZONTAL ELLIPSIS |
| 46 | 0x0086: 0x2020, # DAGGER |
| 47 | 0x0087: 0x2021, # DOUBLE DAGGER |
| 48 | 0x0088: 0x02c6, # MODIFIER LETTER CIRCUMFLEX ACCENT |
| 49 | 0x0089: 0x2030, # PER MILLE SIGN |
| 50 | 0x008a: 0x0679, # ARABIC LETTER TTEH |
| 51 | 0x008b: 0x2039, # SINGLE LEFT-POINTING ANGLE QUOTATION MARK |
| 52 | 0x008c: 0x0152, # LATIN CAPITAL LIGATURE OE |
| 53 | 0x008d: 0x0686, # ARABIC LETTER TCHEH |
| 54 | 0x008e: 0x0698, # ARABIC LETTER JEH |
| 55 | 0x008f: 0x0688, # ARABIC LETTER DDAL |
| 56 | 0x0090: 0x06af, # ARABIC LETTER GAF |
| 57 | 0x0091: 0x2018, # LEFT SINGLE QUOTATION MARK |
| 58 | 0x0092: 0x2019, # RIGHT SINGLE QUOTATION MARK |
| 59 | 0x0093: 0x201c, # LEFT DOUBLE QUOTATION MARK |
| 60 | 0x0094: 0x201d, # RIGHT DOUBLE QUOTATION MARK |
| 61 | 0x0095: 0x2022, # BULLET |
| 62 | 0x0096: 0x2013, # EN DASH |
| 63 | 0x0097: 0x2014, # EM DASH |
| 64 | 0x0098: 0x06a9, # ARABIC LETTER KEHEH |
| 65 | 0x0099: 0x2122, # TRADE MARK SIGN |
| 66 | 0x009a: 0x0691, # ARABIC LETTER RREH |
| 67 | 0x009b: 0x203a, # SINGLE RIGHT-POINTING ANGLE QUOTATION MARK |
| 68 | 0x009c: 0x0153, # LATIN SMALL LIGATURE OE |
| 69 | 0x009d: 0x200c, # ZERO WIDTH NON-JOINER |
| 70 | 0x009e: 0x200d, # ZERO WIDTH JOINER |
| 71 | 0x009f: 0x06ba, # ARABIC LETTER NOON GHUNNA |
| 72 | 0x00a1: 0x060c, # ARABIC COMMA |
| 73 | 0x00aa: 0x06be, # ARABIC LETTER HEH DOACHASHMEE |
| 74 | 0x00ba: 0x061b, # ARABIC SEMICOLON |
| 75 | 0x00bf: 0x061f, # ARABIC QUESTION MARK |
| 76 | 0x00c0: 0x06c1, # ARABIC LETTER HEH GOAL |
| 77 | 0x00c1: 0x0621, # ARABIC LETTER HAMZA |
| 78 | 0x00c2: 0x0622, # ARABIC LETTER ALEF WITH MADDA ABOVE |
| 79 | 0x00c3: 0x0623, # ARABIC LETTER ALEF WITH HAMZA ABOVE |
| 80 | 0x00c4: 0x0624, # ARABIC LETTER WAW WITH HAMZA ABOVE |
| 81 | 0x00c5: 0x0625, # ARABIC LETTER ALEF WITH HAMZA BELOW |
| 82 | 0x00c6: 0x0626, # ARABIC LETTER YEH WITH HAMZA ABOVE |
| 83 | 0x00c7: 0x0627, # ARABIC LETTER ALEF |
| 84 | 0x00c8: 0x0628, # ARABIC LETTER BEH |
| 85 | 0x00c9: 0x0629, # ARABIC LETTER TEH MARBUTA |
| 86 | 0x00ca: 0x062a, # ARABIC LETTER TEH |
| 87 | 0x00cb: 0x062b, # ARABIC LETTER THEH |
| 88 | 0x00cc: 0x062c, # ARABIC LETTER JEEM |
| 89 | 0x00cd: 0x062d, # ARABIC LETTER HAH |
| 90 | 0x00ce: 0x062e, # ARABIC LETTER KHAH |
| 91 | 0x00cf: 0x062f, # ARABIC LETTER DAL |
| 92 | 0x00d0: 0x0630, # ARABIC LETTER THAL |
| 93 | 0x00d1: 0x0631, # ARABIC LETTER REH |
| 94 | 0x00d2: 0x0632, # ARABIC LETTER ZAIN |
| 95 | 0x00d3: 0x0633, # ARABIC LETTER SEEN |
| 96 | 0x00d4: 0x0634, # ARABIC LETTER SHEEN |
| 97 | 0x00d5: 0x0635, # ARABIC LETTER SAD |
| 98 | 0x00d6: 0x0636, # ARABIC LETTER DAD |
| 99 | 0x00d8: 0x0637, # ARABIC LETTER TAH |
| 100 | 0x00d9: 0x0638, # ARABIC LETTER ZAH |
| 101 | 0x00da: 0x0639, # ARABIC LETTER AIN |
| 102 | 0x00db: 0x063a, # ARABIC LETTER GHAIN |
| 103 | 0x00dc: 0x0640, # ARABIC TATWEEL |
| 104 | 0x00dd: 0x0641, # ARABIC LETTER FEH |
| 105 | 0x00de: 0x0642, # ARABIC LETTER QAF |
| 106 | 0x00df: 0x0643, # ARABIC LETTER KAF |
| 107 | 0x00e1: 0x0644, # ARABIC LETTER LAM |
| 108 | 0x00e3: 0x0645, # ARABIC LETTER MEEM |
| 109 | 0x00e4: 0x0646, # ARABIC LETTER NOON |
| 110 | 0x00e5: 0x0647, # ARABIC LETTER HEH |
| 111 | 0x00e6: 0x0648, # ARABIC LETTER WAW |
| 112 | 0x00ec: 0x0649, # ARABIC LETTER ALEF MAKSURA |
| 113 | 0x00ed: 0x064a, # ARABIC LETTER YEH |
| 114 | 0x00f0: 0x064b, # ARABIC FATHATAN |
| 115 | 0x00f1: 0x064c, # ARABIC DAMMATAN |
| 116 | 0x00f2: 0x064d, # ARABIC KASRATAN |
| 117 | 0x00f3: 0x064e, # ARABIC FATHA |
| 118 | 0x00f5: 0x064f, # ARABIC DAMMA |
| 119 | 0x00f6: 0x0650, # ARABIC KASRA |
| 120 | 0x00f8: 0x0651, # ARABIC SHADDA |
| 121 | 0x00fa: 0x0652, # ARABIC SUKUN |
| 122 | 0x00fd: 0x200e, # LEFT-TO-RIGHT MARK |
| 123 | 0x00fe: 0x200f, # RIGHT-TO-LEFT MARK |
| 124 | 0x00ff: 0x06d2, # ARABIC LETTER YEH BARREE |
Marc-André Lemburg | a866df8 | 2001-01-03 21:29:14 +0000 | [diff] [blame] | 125 | }) |
Guido van Rossum | 0229bf6 | 2000-03-10 23:17:24 +0000 | [diff] [blame] | 126 | |
| 127 | ### Encoding Map |
| 128 | |
| 129 | encoding_map = {} |
| 130 | for k,v in decoding_map.items(): |
| 131 | encoding_map[v] = k |