cp500.py 13 KB

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