1""" Python Character Mapping Codec for PalmOS 3.5. 2 3Written by Sjoerd Mullender (sjoerd@acm.org); based on iso8859_15.py. 4 5"""#" 6 7import codecs 8 9### Codec APIs 10 11class Codec(codecs.Codec): 12 def encode(self,input,errors='strict'): 13 return codecs.charmap_encode(input,errors,encoding_table) 14 15 def decode(self,input,errors='strict'): 16 return codecs.charmap_decode(input,errors,decoding_table) 17 18class IncrementalEncoder(codecs.IncrementalEncoder): 19 def encode(self, input, final=False): 20 return codecs.charmap_encode(input,self.errors,encoding_table)[0] 21 22class IncrementalDecoder(codecs.IncrementalDecoder): 23 def decode(self, input, final=False): 24 return codecs.charmap_decode(input,self.errors,decoding_table)[0] 25 26class StreamWriter(Codec,codecs.StreamWriter): 27 pass 28 29class StreamReader(Codec,codecs.StreamReader): 30 pass 31 32### encodings module API 33 34def getregentry(): 35 return codecs.CodecInfo( 36 name='palmos', 37 encode=Codec().encode, 38 decode=Codec().decode, 39 incrementalencoder=IncrementalEncoder, 40 incrementaldecoder=IncrementalDecoder, 41 streamreader=StreamReader, 42 streamwriter=StreamWriter, 43 ) 44 45 46### Decoding Table 47 48decoding_table = ( 49 '\x00' # 0x00 -> NULL 50 '\x01' # 0x01 -> START OF HEADING 51 '\x02' # 0x02 -> START OF TEXT 52 '\x03' # 0x03 -> END OF TEXT 53 '\x04' # 0x04 -> END OF TRANSMISSION 54 '\x05' # 0x05 -> ENQUIRY 55 '\x06' # 0x06 -> ACKNOWLEDGE 56 '\x07' # 0x07 -> BELL 57 '\x08' # 0x08 -> BACKSPACE 58 '\t' # 0x09 -> HORIZONTAL TABULATION 59 '\n' # 0x0A -> LINE FEED 60 '\x0b' # 0x0B -> VERTICAL TABULATION 61 '\x0c' # 0x0C -> FORM FEED 62 '\r' # 0x0D -> CARRIAGE RETURN 63 '\x0e' # 0x0E -> SHIFT OUT 64 '\x0f' # 0x0F -> SHIFT IN 65 '\x10' # 0x10 -> DATA LINK ESCAPE 66 '\x11' # 0x11 -> DEVICE CONTROL ONE 67 '\x12' # 0x12 -> DEVICE CONTROL TWO 68 '\x13' # 0x13 -> DEVICE CONTROL THREE 69 '\x14' # 0x14 -> DEVICE CONTROL FOUR 70 '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE 71 '\x16' # 0x16 -> SYNCHRONOUS IDLE 72 '\x17' # 0x17 -> END OF TRANSMISSION BLOCK 73 '\x18' # 0x18 -> CANCEL 74 '\x19' # 0x19 -> END OF MEDIUM 75 '\x1a' # 0x1A -> SUBSTITUTE 76 '\x1b' # 0x1B -> ESCAPE 77 '\x1c' # 0x1C -> FILE SEPARATOR 78 '\x1d' # 0x1D -> GROUP SEPARATOR 79 '\x1e' # 0x1E -> RECORD SEPARATOR 80 '\x1f' # 0x1F -> UNIT SEPARATOR 81 ' ' # 0x20 -> SPACE 82 '!' # 0x21 -> EXCLAMATION MARK 83 '"' # 0x22 -> QUOTATION MARK 84 '#' # 0x23 -> NUMBER SIGN 85 '$' # 0x24 -> DOLLAR SIGN 86 '%' # 0x25 -> PERCENT SIGN 87 '&' # 0x26 -> AMPERSAND 88 "'" # 0x27 -> APOSTROPHE 89 '(' # 0x28 -> LEFT PARENTHESIS 90 ')' # 0x29 -> RIGHT PARENTHESIS 91 '*' # 0x2A -> ASTERISK 92 '+' # 0x2B -> PLUS SIGN 93 ',' # 0x2C -> COMMA 94 '-' # 0x2D -> HYPHEN-MINUS 95 '.' # 0x2E -> FULL STOP 96 '/' # 0x2F -> SOLIDUS 97 '0' # 0x30 -> DIGIT ZERO 98 '1' # 0x31 -> DIGIT ONE 99 '2' # 0x32 -> DIGIT TWO 100 '3' # 0x33 -> DIGIT THREE 101 '4' # 0x34 -> DIGIT FOUR 102 '5' # 0x35 -> DIGIT FIVE 103 '6' # 0x36 -> DIGIT SIX 104 '7' # 0x37 -> DIGIT SEVEN 105 '8' # 0x38 -> DIGIT EIGHT 106 '9' # 0x39 -> DIGIT NINE 107 ':' # 0x3A -> COLON 108 ';' # 0x3B -> SEMICOLON 109 '<' # 0x3C -> LESS-THAN SIGN 110 '=' # 0x3D -> EQUALS SIGN 111 '>' # 0x3E -> GREATER-THAN SIGN 112 '?' # 0x3F -> QUESTION MARK 113 '@' # 0x40 -> COMMERCIAL AT 114 'A' # 0x41 -> LATIN CAPITAL LETTER A 115 'B' # 0x42 -> LATIN CAPITAL LETTER B 116 'C' # 0x43 -> LATIN CAPITAL LETTER C 117 'D' # 0x44 -> LATIN CAPITAL LETTER D 118 'E' # 0x45 -> LATIN CAPITAL LETTER E 119 'F' # 0x46 -> LATIN CAPITAL LETTER F 120 'G' # 0x47 -> LATIN CAPITAL LETTER G 121 'H' # 0x48 -> LATIN CAPITAL LETTER H 122 'I' # 0x49 -> LATIN CAPITAL LETTER I 123 'J' # 0x4A -> LATIN CAPITAL LETTER J 124 'K' # 0x4B -> LATIN CAPITAL LETTER K 125 'L' # 0x4C -> LATIN CAPITAL LETTER L 126 'M' # 0x4D -> LATIN CAPITAL LETTER M 127 'N' # 0x4E -> LATIN CAPITAL LETTER N 128 'O' # 0x4F -> LATIN CAPITAL LETTER O 129 'P' # 0x50 -> LATIN CAPITAL LETTER P 130 'Q' # 0x51 -> LATIN CAPITAL LETTER Q 131 'R' # 0x52 -> LATIN CAPITAL LETTER R 132 'S' # 0x53 -> LATIN CAPITAL LETTER S 133 'T' # 0x54 -> LATIN CAPITAL LETTER T 134 'U' # 0x55 -> LATIN CAPITAL LETTER U 135 'V' # 0x56 -> LATIN CAPITAL LETTER V 136 'W' # 0x57 -> LATIN CAPITAL LETTER W 137 'X' # 0x58 -> LATIN CAPITAL LETTER X 138 'Y' # 0x59 -> LATIN CAPITAL LETTER Y 139 'Z' # 0x5A -> LATIN CAPITAL LETTER Z 140 '[' # 0x5B -> LEFT SQUARE BRACKET 141 '\\' # 0x5C -> REVERSE SOLIDUS 142 ']' # 0x5D -> RIGHT SQUARE BRACKET 143 '^' # 0x5E -> CIRCUMFLEX ACCENT 144 '_' # 0x5F -> LOW LINE 145 '`' # 0x60 -> GRAVE ACCENT 146 'a' # 0x61 -> LATIN SMALL LETTER A 147 'b' # 0x62 -> LATIN SMALL LETTER B 148 'c' # 0x63 -> LATIN SMALL LETTER C 149 'd' # 0x64 -> LATIN SMALL LETTER D 150 'e' # 0x65 -> LATIN SMALL LETTER E 151 'f' # 0x66 -> LATIN SMALL LETTER F 152 'g' # 0x67 -> LATIN SMALL LETTER G 153 'h' # 0x68 -> LATIN SMALL LETTER H 154 'i' # 0x69 -> LATIN SMALL LETTER I 155 'j' # 0x6A -> LATIN SMALL LETTER J 156 'k' # 0x6B -> LATIN SMALL LETTER K 157 'l' # 0x6C -> LATIN SMALL LETTER L 158 'm' # 0x6D -> LATIN SMALL LETTER M 159 'n' # 0x6E -> LATIN SMALL LETTER N 160 'o' # 0x6F -> LATIN SMALL LETTER O 161 'p' # 0x70 -> LATIN SMALL LETTER P 162 'q' # 0x71 -> LATIN SMALL LETTER Q 163 'r' # 0x72 -> LATIN SMALL LETTER R 164 's' # 0x73 -> LATIN SMALL LETTER S 165 't' # 0x74 -> LATIN SMALL LETTER T 166 'u' # 0x75 -> LATIN SMALL LETTER U 167 'v' # 0x76 -> LATIN SMALL LETTER V 168 'w' # 0x77 -> LATIN SMALL LETTER W 169 'x' # 0x78 -> LATIN SMALL LETTER X 170 'y' # 0x79 -> LATIN SMALL LETTER Y 171 'z' # 0x7A -> LATIN SMALL LETTER Z 172 '{' # 0x7B -> LEFT CURLY BRACKET 173 '|' # 0x7C -> VERTICAL LINE 174 '}' # 0x7D -> RIGHT CURLY BRACKET 175 '~' # 0x7E -> TILDE 176 '\x7f' # 0x7F -> DELETE 177 '\u20ac' # 0x80 -> EURO SIGN 178 '\x81' # 0x81 -> <control> 179 '\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK 180 '\u0192' # 0x83 -> LATIN SMALL LETTER F WITH HOOK 181 '\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK 182 '\u2026' # 0x85 -> HORIZONTAL ELLIPSIS 183 '\u2020' # 0x86 -> DAGGER 184 '\u2021' # 0x87 -> DOUBLE DAGGER 185 '\u02c6' # 0x88 -> MODIFIER LETTER CIRCUMFLEX ACCENT 186 '\u2030' # 0x89 -> PER MILLE SIGN 187 '\u0160' # 0x8A -> LATIN CAPITAL LETTER S WITH CARON 188 '\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK 189 '\u0152' # 0x8C -> LATIN CAPITAL LIGATURE OE 190 '\u2666' # 0x8D -> BLACK DIAMOND SUIT 191 '\u2663' # 0x8E -> BLACK CLUB SUIT 192 '\u2665' # 0x8F -> BLACK HEART SUIT 193 '\u2660' # 0x90 -> BLACK SPADE SUIT 194 '\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK 195 '\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK 196 '\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK 197 '\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK 198 '\u2022' # 0x95 -> BULLET 199 '\u2013' # 0x96 -> EN DASH 200 '\u2014' # 0x97 -> EM DASH 201 '\u02dc' # 0x98 -> SMALL TILDE 202 '\u2122' # 0x99 -> TRADE MARK SIGN 203 '\u0161' # 0x9A -> LATIN SMALL LETTER S WITH CARON 204 '\x9b' # 0x9B -> <control> 205 '\u0153' # 0x9C -> LATIN SMALL LIGATURE OE 206 '\x9d' # 0x9D -> <control> 207 '\x9e' # 0x9E -> <control> 208 '\u0178' # 0x9F -> LATIN CAPITAL LETTER Y WITH DIAERESIS 209 '\xa0' # 0xA0 -> NO-BREAK SPACE 210 '\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK 211 '\xa2' # 0xA2 -> CENT SIGN 212 '\xa3' # 0xA3 -> POUND SIGN 213 '\xa4' # 0xA4 -> CURRENCY SIGN 214 '\xa5' # 0xA5 -> YEN SIGN 215 '\xa6' # 0xA6 -> BROKEN BAR 216 '\xa7' # 0xA7 -> SECTION SIGN 217 '\xa8' # 0xA8 -> DIAERESIS 218 '\xa9' # 0xA9 -> COPYRIGHT SIGN 219 '\xaa' # 0xAA -> FEMININE ORDINAL INDICATOR 220 '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 221 '\xac' # 0xAC -> NOT SIGN 222 '\xad' # 0xAD -> SOFT HYPHEN 223 '\xae' # 0xAE -> REGISTERED SIGN 224 '\xaf' # 0xAF -> MACRON 225 '\xb0' # 0xB0 -> DEGREE SIGN 226 '\xb1' # 0xB1 -> PLUS-MINUS SIGN 227 '\xb2' # 0xB2 -> SUPERSCRIPT TWO 228 '\xb3' # 0xB3 -> SUPERSCRIPT THREE 229 '\xb4' # 0xB4 -> ACUTE ACCENT 230 '\xb5' # 0xB5 -> MICRO SIGN 231 '\xb6' # 0xB6 -> PILCROW SIGN 232 '\xb7' # 0xB7 -> MIDDLE DOT 233 '\xb8' # 0xB8 -> CEDILLA 234 '\xb9' # 0xB9 -> SUPERSCRIPT ONE 235 '\xba' # 0xBA -> MASCULINE ORDINAL INDICATOR 236 '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK 237 '\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER 238 '\xbd' # 0xBD -> VULGAR FRACTION ONE HALF 239 '\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS 240 '\xbf' # 0xBF -> INVERTED QUESTION MARK 241 '\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE 242 '\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE 243 '\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX 244 '\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE 245 '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS 246 '\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE 247 '\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE 248 '\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA 249 '\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE 250 '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE 251 '\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX 252 '\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS 253 '\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE 254 '\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE 255 '\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX 256 '\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS 257 '\xd0' # 0xD0 -> LATIN CAPITAL LETTER ETH (Icelandic) 258 '\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE 259 '\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE 260 '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE 261 '\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX 262 '\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE 263 '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS 264 '\xd7' # 0xD7 -> MULTIPLICATION SIGN 265 '\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE 266 '\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE 267 '\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE 268 '\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX 269 '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS 270 '\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE 271 '\xde' # 0xDE -> LATIN CAPITAL LETTER THORN (Icelandic) 272 '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S (German) 273 '\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE 274 '\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE 275 '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX 276 '\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE 277 '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS 278 '\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE 279 '\xe6' # 0xE6 -> LATIN SMALL LETTER AE 280 '\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA 281 '\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE 282 '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE 283 '\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX 284 '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS 285 '\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE 286 '\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE 287 '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX 288 '\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS 289 '\xf0' # 0xF0 -> LATIN SMALL LETTER ETH (Icelandic) 290 '\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE 291 '\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE 292 '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE 293 '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX 294 '\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE 295 '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS 296 '\xf7' # 0xF7 -> DIVISION SIGN 297 '\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE 298 '\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE 299 '\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE 300 '\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX 301 '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS 302 '\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE 303 '\xfe' # 0xFE -> LATIN SMALL LETTER THORN (Icelandic) 304 '\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS 305) 306 307### Encoding table 308encoding_table=codecs.charmap_build(decoding_table) 309