mac_farsi.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. """ Python Character Mapping Codec mac_farsi generated from 'MAPPINGS/VENDORS/APPLE/FARSI.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='mac-farsi',
  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 -> CONTROL CHARACTER
  34. '\x01' # 0x01 -> CONTROL CHARACTER
  35. '\x02' # 0x02 -> CONTROL CHARACTER
  36. '\x03' # 0x03 -> CONTROL CHARACTER
  37. '\x04' # 0x04 -> CONTROL CHARACTER
  38. '\x05' # 0x05 -> CONTROL CHARACTER
  39. '\x06' # 0x06 -> CONTROL CHARACTER
  40. '\x07' # 0x07 -> CONTROL CHARACTER
  41. '\x08' # 0x08 -> CONTROL CHARACTER
  42. '\t' # 0x09 -> CONTROL CHARACTER
  43. '\n' # 0x0A -> CONTROL CHARACTER
  44. '\x0b' # 0x0B -> CONTROL CHARACTER
  45. '\x0c' # 0x0C -> CONTROL CHARACTER
  46. '\r' # 0x0D -> CONTROL CHARACTER
  47. '\x0e' # 0x0E -> CONTROL CHARACTER
  48. '\x0f' # 0x0F -> CONTROL CHARACTER
  49. '\x10' # 0x10 -> CONTROL CHARACTER
  50. '\x11' # 0x11 -> CONTROL CHARACTER
  51. '\x12' # 0x12 -> CONTROL CHARACTER
  52. '\x13' # 0x13 -> CONTROL CHARACTER
  53. '\x14' # 0x14 -> CONTROL CHARACTER
  54. '\x15' # 0x15 -> CONTROL CHARACTER
  55. '\x16' # 0x16 -> CONTROL CHARACTER
  56. '\x17' # 0x17 -> CONTROL CHARACTER
  57. '\x18' # 0x18 -> CONTROL CHARACTER
  58. '\x19' # 0x19 -> CONTROL CHARACTER
  59. '\x1a' # 0x1A -> CONTROL CHARACTER
  60. '\x1b' # 0x1B -> CONTROL CHARACTER
  61. '\x1c' # 0x1C -> CONTROL CHARACTER
  62. '\x1d' # 0x1D -> CONTROL CHARACTER
  63. '\x1e' # 0x1E -> CONTROL CHARACTER
  64. '\x1f' # 0x1F -> CONTROL CHARACTER
  65. ' ' # 0x20 -> SPACE, left-right
  66. '!' # 0x21 -> EXCLAMATION MARK, left-right
  67. '"' # 0x22 -> QUOTATION MARK, left-right
  68. '#' # 0x23 -> NUMBER SIGN, left-right
  69. '$' # 0x24 -> DOLLAR SIGN, left-right
  70. '%' # 0x25 -> PERCENT SIGN, left-right
  71. '&' # 0x26 -> AMPERSAND, left-right
  72. "'" # 0x27 -> APOSTROPHE, left-right
  73. '(' # 0x28 -> LEFT PARENTHESIS, left-right
  74. ')' # 0x29 -> RIGHT PARENTHESIS, left-right
  75. '*' # 0x2A -> ASTERISK, left-right
  76. '+' # 0x2B -> PLUS SIGN, left-right
  77. ',' # 0x2C -> COMMA, left-right; in Arabic-script context, displayed as 0x066C ARABIC THOUSANDS SEPARATOR
  78. '-' # 0x2D -> HYPHEN-MINUS, left-right
  79. '.' # 0x2E -> FULL STOP, left-right; in Arabic-script context, displayed as 0x066B ARABIC DECIMAL SEPARATOR
  80. '/' # 0x2F -> SOLIDUS, left-right
  81. '0' # 0x30 -> DIGIT ZERO; in Arabic-script context, displayed as 0x06F0 EXTENDED ARABIC-INDIC DIGIT ZERO
  82. '1' # 0x31 -> DIGIT ONE; in Arabic-script context, displayed as 0x06F1 EXTENDED ARABIC-INDIC DIGIT ONE
  83. '2' # 0x32 -> DIGIT TWO; in Arabic-script context, displayed as 0x06F2 EXTENDED ARABIC-INDIC DIGIT TWO
  84. '3' # 0x33 -> DIGIT THREE; in Arabic-script context, displayed as 0x06F3 EXTENDED ARABIC-INDIC DIGIT THREE
  85. '4' # 0x34 -> DIGIT FOUR; in Arabic-script context, displayed as 0x06F4 EXTENDED ARABIC-INDIC DIGIT FOUR
  86. '5' # 0x35 -> DIGIT FIVE; in Arabic-script context, displayed as 0x06F5 EXTENDED ARABIC-INDIC DIGIT FIVE
  87. '6' # 0x36 -> DIGIT SIX; in Arabic-script context, displayed as 0x06F6 EXTENDED ARABIC-INDIC DIGIT SIX
  88. '7' # 0x37 -> DIGIT SEVEN; in Arabic-script context, displayed as 0x06F7 EXTENDED ARABIC-INDIC DIGIT SEVEN
  89. '8' # 0x38 -> DIGIT EIGHT; in Arabic-script context, displayed as 0x06F8 EXTENDED ARABIC-INDIC DIGIT EIGHT
  90. '9' # 0x39 -> DIGIT NINE; in Arabic-script context, displayed as 0x06F9 EXTENDED ARABIC-INDIC DIGIT NINE
  91. ':' # 0x3A -> COLON, left-right
  92. ';' # 0x3B -> SEMICOLON, left-right
  93. '<' # 0x3C -> LESS-THAN SIGN, left-right
  94. '=' # 0x3D -> EQUALS SIGN, left-right
  95. '>' # 0x3E -> GREATER-THAN SIGN, left-right
  96. '?' # 0x3F -> QUESTION MARK, left-right
  97. '@' # 0x40 -> COMMERCIAL AT
  98. 'A' # 0x41 -> LATIN CAPITAL LETTER A
  99. 'B' # 0x42 -> LATIN CAPITAL LETTER B
  100. 'C' # 0x43 -> LATIN CAPITAL LETTER C
  101. 'D' # 0x44 -> LATIN CAPITAL LETTER D
  102. 'E' # 0x45 -> LATIN CAPITAL LETTER E
  103. 'F' # 0x46 -> LATIN CAPITAL LETTER F
  104. 'G' # 0x47 -> LATIN CAPITAL LETTER G
  105. 'H' # 0x48 -> LATIN CAPITAL LETTER H
  106. 'I' # 0x49 -> LATIN CAPITAL LETTER I
  107. 'J' # 0x4A -> LATIN CAPITAL LETTER J
  108. 'K' # 0x4B -> LATIN CAPITAL LETTER K
  109. 'L' # 0x4C -> LATIN CAPITAL LETTER L
  110. 'M' # 0x4D -> LATIN CAPITAL LETTER M
  111. 'N' # 0x4E -> LATIN CAPITAL LETTER N
  112. 'O' # 0x4F -> LATIN CAPITAL LETTER O
  113. 'P' # 0x50 -> LATIN CAPITAL LETTER P
  114. 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
  115. 'R' # 0x52 -> LATIN CAPITAL LETTER R
  116. 'S' # 0x53 -> LATIN CAPITAL LETTER S
  117. 'T' # 0x54 -> LATIN CAPITAL LETTER T
  118. 'U' # 0x55 -> LATIN CAPITAL LETTER U
  119. 'V' # 0x56 -> LATIN CAPITAL LETTER V
  120. 'W' # 0x57 -> LATIN CAPITAL LETTER W
  121. 'X' # 0x58 -> LATIN CAPITAL LETTER X
  122. 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
  123. 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
  124. '[' # 0x5B -> LEFT SQUARE BRACKET, left-right
  125. '\\' # 0x5C -> REVERSE SOLIDUS, left-right
  126. ']' # 0x5D -> RIGHT SQUARE BRACKET, left-right
  127. '^' # 0x5E -> CIRCUMFLEX ACCENT, left-right
  128. '_' # 0x5F -> LOW LINE, left-right
  129. '`' # 0x60 -> GRAVE ACCENT
  130. 'a' # 0x61 -> LATIN SMALL LETTER A
  131. 'b' # 0x62 -> LATIN SMALL LETTER B
  132. 'c' # 0x63 -> LATIN SMALL LETTER C
  133. 'd' # 0x64 -> LATIN SMALL LETTER D
  134. 'e' # 0x65 -> LATIN SMALL LETTER E
  135. 'f' # 0x66 -> LATIN SMALL LETTER F
  136. 'g' # 0x67 -> LATIN SMALL LETTER G
  137. 'h' # 0x68 -> LATIN SMALL LETTER H
  138. 'i' # 0x69 -> LATIN SMALL LETTER I
  139. 'j' # 0x6A -> LATIN SMALL LETTER J
  140. 'k' # 0x6B -> LATIN SMALL LETTER K
  141. 'l' # 0x6C -> LATIN SMALL LETTER L
  142. 'm' # 0x6D -> LATIN SMALL LETTER M
  143. 'n' # 0x6E -> LATIN SMALL LETTER N
  144. 'o' # 0x6F -> LATIN SMALL LETTER O
  145. 'p' # 0x70 -> LATIN SMALL LETTER P
  146. 'q' # 0x71 -> LATIN SMALL LETTER Q
  147. 'r' # 0x72 -> LATIN SMALL LETTER R
  148. 's' # 0x73 -> LATIN SMALL LETTER S
  149. 't' # 0x74 -> LATIN SMALL LETTER T
  150. 'u' # 0x75 -> LATIN SMALL LETTER U
  151. 'v' # 0x76 -> LATIN SMALL LETTER V
  152. 'w' # 0x77 -> LATIN SMALL LETTER W
  153. 'x' # 0x78 -> LATIN SMALL LETTER X
  154. 'y' # 0x79 -> LATIN SMALL LETTER Y
  155. 'z' # 0x7A -> LATIN SMALL LETTER Z
  156. '{' # 0x7B -> LEFT CURLY BRACKET, left-right
  157. '|' # 0x7C -> VERTICAL LINE, left-right
  158. '}' # 0x7D -> RIGHT CURLY BRACKET, left-right
  159. '~' # 0x7E -> TILDE
  160. '\x7f' # 0x7F -> CONTROL CHARACTER
  161. '\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
  162. '\xa0' # 0x81 -> NO-BREAK SPACE, right-left
  163. '\xc7' # 0x82 -> LATIN CAPITAL LETTER C WITH CEDILLA
  164. '\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
  165. '\xd1' # 0x84 -> LATIN CAPITAL LETTER N WITH TILDE
  166. '\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
  167. '\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
  168. '\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE
  169. '\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE
  170. '\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
  171. '\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
  172. '\u06ba' # 0x8B -> ARABIC LETTER NOON GHUNNA
  173. '\xab' # 0x8C -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK, right-left
  174. '\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA
  175. '\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
  176. '\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE
  177. '\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
  178. '\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS
  179. '\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
  180. '\u2026' # 0x93 -> HORIZONTAL ELLIPSIS, right-left
  181. '\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
  182. '\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS
  183. '\xf1' # 0x96 -> LATIN SMALL LETTER N WITH TILDE
  184. '\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
  185. '\xbb' # 0x98 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK, right-left
  186. '\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
  187. '\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
  188. '\xf7' # 0x9B -> DIVISION SIGN, right-left
  189. '\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE
  190. '\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE
  191. '\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX
  192. '\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
  193. ' ' # 0xA0 -> SPACE, right-left
  194. '!' # 0xA1 -> EXCLAMATION MARK, right-left
  195. '"' # 0xA2 -> QUOTATION MARK, right-left
  196. '#' # 0xA3 -> NUMBER SIGN, right-left
  197. '$' # 0xA4 -> DOLLAR SIGN, right-left
  198. '\u066a' # 0xA5 -> ARABIC PERCENT SIGN
  199. '&' # 0xA6 -> AMPERSAND, right-left
  200. "'" # 0xA7 -> APOSTROPHE, right-left
  201. '(' # 0xA8 -> LEFT PARENTHESIS, right-left
  202. ')' # 0xA9 -> RIGHT PARENTHESIS, right-left
  203. '*' # 0xAA -> ASTERISK, right-left
  204. '+' # 0xAB -> PLUS SIGN, right-left
  205. '\u060c' # 0xAC -> ARABIC COMMA
  206. '-' # 0xAD -> HYPHEN-MINUS, right-left
  207. '.' # 0xAE -> FULL STOP, right-left
  208. '/' # 0xAF -> SOLIDUS, right-left
  209. '\u06f0' # 0xB0 -> EXTENDED ARABIC-INDIC DIGIT ZERO, right-left (need override)
  210. '\u06f1' # 0xB1 -> EXTENDED ARABIC-INDIC DIGIT ONE, right-left (need override)
  211. '\u06f2' # 0xB2 -> EXTENDED ARABIC-INDIC DIGIT TWO, right-left (need override)
  212. '\u06f3' # 0xB3 -> EXTENDED ARABIC-INDIC DIGIT THREE, right-left (need override)
  213. '\u06f4' # 0xB4 -> EXTENDED ARABIC-INDIC DIGIT FOUR, right-left (need override)
  214. '\u06f5' # 0xB5 -> EXTENDED ARABIC-INDIC DIGIT FIVE, right-left (need override)
  215. '\u06f6' # 0xB6 -> EXTENDED ARABIC-INDIC DIGIT SIX, right-left (need override)
  216. '\u06f7' # 0xB7 -> EXTENDED ARABIC-INDIC DIGIT SEVEN, right-left (need override)
  217. '\u06f8' # 0xB8 -> EXTENDED ARABIC-INDIC DIGIT EIGHT, right-left (need override)
  218. '\u06f9' # 0xB9 -> EXTENDED ARABIC-INDIC DIGIT NINE, right-left (need override)
  219. ':' # 0xBA -> COLON, right-left
  220. '\u061b' # 0xBB -> ARABIC SEMICOLON
  221. '<' # 0xBC -> LESS-THAN SIGN, right-left
  222. '=' # 0xBD -> EQUALS SIGN, right-left
  223. '>' # 0xBE -> GREATER-THAN SIGN, right-left
  224. '\u061f' # 0xBF -> ARABIC QUESTION MARK
  225. '\u274a' # 0xC0 -> EIGHT TEARDROP-SPOKED PROPELLER ASTERISK, right-left
  226. '\u0621' # 0xC1 -> ARABIC LETTER HAMZA
  227. '\u0622' # 0xC2 -> ARABIC LETTER ALEF WITH MADDA ABOVE
  228. '\u0623' # 0xC3 -> ARABIC LETTER ALEF WITH HAMZA ABOVE
  229. '\u0624' # 0xC4 -> ARABIC LETTER WAW WITH HAMZA ABOVE
  230. '\u0625' # 0xC5 -> ARABIC LETTER ALEF WITH HAMZA BELOW
  231. '\u0626' # 0xC6 -> ARABIC LETTER YEH WITH HAMZA ABOVE
  232. '\u0627' # 0xC7 -> ARABIC LETTER ALEF
  233. '\u0628' # 0xC8 -> ARABIC LETTER BEH
  234. '\u0629' # 0xC9 -> ARABIC LETTER TEH MARBUTA
  235. '\u062a' # 0xCA -> ARABIC LETTER TEH
  236. '\u062b' # 0xCB -> ARABIC LETTER THEH
  237. '\u062c' # 0xCC -> ARABIC LETTER JEEM
  238. '\u062d' # 0xCD -> ARABIC LETTER HAH
  239. '\u062e' # 0xCE -> ARABIC LETTER KHAH
  240. '\u062f' # 0xCF -> ARABIC LETTER DAL
  241. '\u0630' # 0xD0 -> ARABIC LETTER THAL
  242. '\u0631' # 0xD1 -> ARABIC LETTER REH
  243. '\u0632' # 0xD2 -> ARABIC LETTER ZAIN
  244. '\u0633' # 0xD3 -> ARABIC LETTER SEEN
  245. '\u0634' # 0xD4 -> ARABIC LETTER SHEEN
  246. '\u0635' # 0xD5 -> ARABIC LETTER SAD
  247. '\u0636' # 0xD6 -> ARABIC LETTER DAD
  248. '\u0637' # 0xD7 -> ARABIC LETTER TAH
  249. '\u0638' # 0xD8 -> ARABIC LETTER ZAH
  250. '\u0639' # 0xD9 -> ARABIC LETTER AIN
  251. '\u063a' # 0xDA -> ARABIC LETTER GHAIN
  252. '[' # 0xDB -> LEFT SQUARE BRACKET, right-left
  253. '\\' # 0xDC -> REVERSE SOLIDUS, right-left
  254. ']' # 0xDD -> RIGHT SQUARE BRACKET, right-left
  255. '^' # 0xDE -> CIRCUMFLEX ACCENT, right-left
  256. '_' # 0xDF -> LOW LINE, right-left
  257. '\u0640' # 0xE0 -> ARABIC TATWEEL
  258. '\u0641' # 0xE1 -> ARABIC LETTER FEH
  259. '\u0642' # 0xE2 -> ARABIC LETTER QAF
  260. '\u0643' # 0xE3 -> ARABIC LETTER KAF
  261. '\u0644' # 0xE4 -> ARABIC LETTER LAM
  262. '\u0645' # 0xE5 -> ARABIC LETTER MEEM
  263. '\u0646' # 0xE6 -> ARABIC LETTER NOON
  264. '\u0647' # 0xE7 -> ARABIC LETTER HEH
  265. '\u0648' # 0xE8 -> ARABIC LETTER WAW
  266. '\u0649' # 0xE9 -> ARABIC LETTER ALEF MAKSURA
  267. '\u064a' # 0xEA -> ARABIC LETTER YEH
  268. '\u064b' # 0xEB -> ARABIC FATHATAN
  269. '\u064c' # 0xEC -> ARABIC DAMMATAN
  270. '\u064d' # 0xED -> ARABIC KASRATAN
  271. '\u064e' # 0xEE -> ARABIC FATHA
  272. '\u064f' # 0xEF -> ARABIC DAMMA
  273. '\u0650' # 0xF0 -> ARABIC KASRA
  274. '\u0651' # 0xF1 -> ARABIC SHADDA
  275. '\u0652' # 0xF2 -> ARABIC SUKUN
  276. '\u067e' # 0xF3 -> ARABIC LETTER PEH
  277. '\u0679' # 0xF4 -> ARABIC LETTER TTEH
  278. '\u0686' # 0xF5 -> ARABIC LETTER TCHEH
  279. '\u06d5' # 0xF6 -> ARABIC LETTER AE
  280. '\u06a4' # 0xF7 -> ARABIC LETTER VEH
  281. '\u06af' # 0xF8 -> ARABIC LETTER GAF
  282. '\u0688' # 0xF9 -> ARABIC LETTER DDAL
  283. '\u0691' # 0xFA -> ARABIC LETTER RREH
  284. '{' # 0xFB -> LEFT CURLY BRACKET, right-left
  285. '|' # 0xFC -> VERTICAL LINE, right-left
  286. '}' # 0xFD -> RIGHT CURLY BRACKET, right-left
  287. '\u0698' # 0xFE -> ARABIC LETTER JEH
  288. '\u06d2' # 0xFF -> ARABIC LETTER YEH BARREE
  289. )
  290. ### Encoding table
  291. encoding_table=codecs.charmap_build(decoding_table)