You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

246 lines
10 KiB

4 years ago
  1. ######################## BEGIN LICENSE BLOCK ########################
  2. # The Original Code is mozilla.org code.
  3. #
  4. # The Initial Developer of the Original Code is
  5. # Netscape Communications Corporation.
  6. # Portions created by the Initial Developer are Copyright (C) 1998
  7. # the Initial Developer. All Rights Reserved.
  8. #
  9. # Contributor(s):
  10. # Mark Pilgrim - port to Python
  11. #
  12. # This library is free software; you can redistribute it and/or
  13. # modify it under the terms of the GNU Lesser General Public
  14. # License as published by the Free Software Foundation; either
  15. # version 2.1 of the License, or (at your option) any later version.
  16. #
  17. # This library is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. # Lesser General Public License for more details.
  21. #
  22. # You should have received a copy of the GNU Lesser General Public
  23. # License along with this library; if not, write to the Free Software
  24. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  25. # 02110-1301 USA
  26. ######################### END LICENSE BLOCK #########################
  27. from .enums import MachineState
  28. HZ_CLS = (
  29. 1,0,0,0,0,0,0,0, # 00 - 07
  30. 0,0,0,0,0,0,0,0, # 08 - 0f
  31. 0,0,0,0,0,0,0,0, # 10 - 17
  32. 0,0,0,1,0,0,0,0, # 18 - 1f
  33. 0,0,0,0,0,0,0,0, # 20 - 27
  34. 0,0,0,0,0,0,0,0, # 28 - 2f
  35. 0,0,0,0,0,0,0,0, # 30 - 37
  36. 0,0,0,0,0,0,0,0, # 38 - 3f
  37. 0,0,0,0,0,0,0,0, # 40 - 47
  38. 0,0,0,0,0,0,0,0, # 48 - 4f
  39. 0,0,0,0,0,0,0,0, # 50 - 57
  40. 0,0,0,0,0,0,0,0, # 58 - 5f
  41. 0,0,0,0,0,0,0,0, # 60 - 67
  42. 0,0,0,0,0,0,0,0, # 68 - 6f
  43. 0,0,0,0,0,0,0,0, # 70 - 77
  44. 0,0,0,4,0,5,2,0, # 78 - 7f
  45. 1,1,1,1,1,1,1,1, # 80 - 87
  46. 1,1,1,1,1,1,1,1, # 88 - 8f
  47. 1,1,1,1,1,1,1,1, # 90 - 97
  48. 1,1,1,1,1,1,1,1, # 98 - 9f
  49. 1,1,1,1,1,1,1,1, # a0 - a7
  50. 1,1,1,1,1,1,1,1, # a8 - af
  51. 1,1,1,1,1,1,1,1, # b0 - b7
  52. 1,1,1,1,1,1,1,1, # b8 - bf
  53. 1,1,1,1,1,1,1,1, # c0 - c7
  54. 1,1,1,1,1,1,1,1, # c8 - cf
  55. 1,1,1,1,1,1,1,1, # d0 - d7
  56. 1,1,1,1,1,1,1,1, # d8 - df
  57. 1,1,1,1,1,1,1,1, # e0 - e7
  58. 1,1,1,1,1,1,1,1, # e8 - ef
  59. 1,1,1,1,1,1,1,1, # f0 - f7
  60. 1,1,1,1,1,1,1,1, # f8 - ff
  61. )
  62. HZ_ST = (
  63. MachineState.START,MachineState.ERROR, 3,MachineState.START,MachineState.START,MachineState.START,MachineState.ERROR,MachineState.ERROR,# 00-07
  64. MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 08-0f
  65. MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.START,MachineState.START, 4,MachineState.ERROR,# 10-17
  66. 5,MachineState.ERROR, 6,MachineState.ERROR, 5, 5, 4,MachineState.ERROR,# 18-1f
  67. 4,MachineState.ERROR, 4, 4, 4,MachineState.ERROR, 4,MachineState.ERROR,# 20-27
  68. 4,MachineState.ITS_ME,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 28-2f
  69. )
  70. HZ_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0)
  71. HZ_SM_MODEL = {'class_table': HZ_CLS,
  72. 'class_factor': 6,
  73. 'state_table': HZ_ST,
  74. 'char_len_table': HZ_CHAR_LEN_TABLE,
  75. 'name': "HZ-GB-2312",
  76. 'language': 'Chinese'}
  77. ISO2022CN_CLS = (
  78. 2,0,0,0,0,0,0,0, # 00 - 07
  79. 0,0,0,0,0,0,0,0, # 08 - 0f
  80. 0,0,0,0,0,0,0,0, # 10 - 17
  81. 0,0,0,1,0,0,0,0, # 18 - 1f
  82. 0,0,0,0,0,0,0,0, # 20 - 27
  83. 0,3,0,0,0,0,0,0, # 28 - 2f
  84. 0,0,0,0,0,0,0,0, # 30 - 37
  85. 0,0,0,0,0,0,0,0, # 38 - 3f
  86. 0,0,0,4,0,0,0,0, # 40 - 47
  87. 0,0,0,0,0,0,0,0, # 48 - 4f
  88. 0,0,0,0,0,0,0,0, # 50 - 57
  89. 0,0,0,0,0,0,0,0, # 58 - 5f
  90. 0,0,0,0,0,0,0,0, # 60 - 67
  91. 0,0,0,0,0,0,0,0, # 68 - 6f
  92. 0,0,0,0,0,0,0,0, # 70 - 77
  93. 0,0,0,0,0,0,0,0, # 78 - 7f
  94. 2,2,2,2,2,2,2,2, # 80 - 87
  95. 2,2,2,2,2,2,2,2, # 88 - 8f
  96. 2,2,2,2,2,2,2,2, # 90 - 97
  97. 2,2,2,2,2,2,2,2, # 98 - 9f
  98. 2,2,2,2,2,2,2,2, # a0 - a7
  99. 2,2,2,2,2,2,2,2, # a8 - af
  100. 2,2,2,2,2,2,2,2, # b0 - b7
  101. 2,2,2,2,2,2,2,2, # b8 - bf
  102. 2,2,2,2,2,2,2,2, # c0 - c7
  103. 2,2,2,2,2,2,2,2, # c8 - cf
  104. 2,2,2,2,2,2,2,2, # d0 - d7
  105. 2,2,2,2,2,2,2,2, # d8 - df
  106. 2,2,2,2,2,2,2,2, # e0 - e7
  107. 2,2,2,2,2,2,2,2, # e8 - ef
  108. 2,2,2,2,2,2,2,2, # f0 - f7
  109. 2,2,2,2,2,2,2,2, # f8 - ff
  110. )
  111. ISO2022CN_ST = (
  112. MachineState.START, 3,MachineState.ERROR,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 00-07
  113. MachineState.START,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 08-0f
  114. MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 10-17
  115. MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 4,MachineState.ERROR,# 18-1f
  116. MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 20-27
  117. 5, 6,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 28-2f
  118. MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 30-37
  119. MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.START,# 38-3f
  120. )
  121. ISO2022CN_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0, 0, 0, 0)
  122. ISO2022CN_SM_MODEL = {'class_table': ISO2022CN_CLS,
  123. 'class_factor': 9,
  124. 'state_table': ISO2022CN_ST,
  125. 'char_len_table': ISO2022CN_CHAR_LEN_TABLE,
  126. 'name': "ISO-2022-CN",
  127. 'language': 'Chinese'}
  128. ISO2022JP_CLS = (
  129. 2,0,0,0,0,0,0,0, # 00 - 07
  130. 0,0,0,0,0,0,2,2, # 08 - 0f
  131. 0,0,0,0,0,0,0,0, # 10 - 17
  132. 0,0,0,1,0,0,0,0, # 18 - 1f
  133. 0,0,0,0,7,0,0,0, # 20 - 27
  134. 3,0,0,0,0,0,0,0, # 28 - 2f
  135. 0,0,0,0,0,0,0,0, # 30 - 37
  136. 0,0,0,0,0,0,0,0, # 38 - 3f
  137. 6,0,4,0,8,0,0,0, # 40 - 47
  138. 0,9,5,0,0,0,0,0, # 48 - 4f
  139. 0,0,0,0,0,0,0,0, # 50 - 57
  140. 0,0,0,0,0,0,0,0, # 58 - 5f
  141. 0,0,0,0,0,0,0,0, # 60 - 67
  142. 0,0,0,0,0,0,0,0, # 68 - 6f
  143. 0,0,0,0,0,0,0,0, # 70 - 77
  144. 0,0,0,0,0,0,0,0, # 78 - 7f
  145. 2,2,2,2,2,2,2,2, # 80 - 87
  146. 2,2,2,2,2,2,2,2, # 88 - 8f
  147. 2,2,2,2,2,2,2,2, # 90 - 97
  148. 2,2,2,2,2,2,2,2, # 98 - 9f
  149. 2,2,2,2,2,2,2,2, # a0 - a7
  150. 2,2,2,2,2,2,2,2, # a8 - af
  151. 2,2,2,2,2,2,2,2, # b0 - b7
  152. 2,2,2,2,2,2,2,2, # b8 - bf
  153. 2,2,2,2,2,2,2,2, # c0 - c7
  154. 2,2,2,2,2,2,2,2, # c8 - cf
  155. 2,2,2,2,2,2,2,2, # d0 - d7
  156. 2,2,2,2,2,2,2,2, # d8 - df
  157. 2,2,2,2,2,2,2,2, # e0 - e7
  158. 2,2,2,2,2,2,2,2, # e8 - ef
  159. 2,2,2,2,2,2,2,2, # f0 - f7
  160. 2,2,2,2,2,2,2,2, # f8 - ff
  161. )
  162. ISO2022JP_ST = (
  163. MachineState.START, 3,MachineState.ERROR,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 00-07
  164. MachineState.START,MachineState.START,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 08-0f
  165. MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 10-17
  166. MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,# 18-1f
  167. MachineState.ERROR, 5,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 4,MachineState.ERROR,MachineState.ERROR,# 20-27
  168. MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 6,MachineState.ITS_ME,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,# 28-2f
  169. MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,# 30-37
  170. MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 38-3f
  171. MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.START,MachineState.START,# 40-47
  172. )
  173. ISO2022JP_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
  174. ISO2022JP_SM_MODEL = {'class_table': ISO2022JP_CLS,
  175. 'class_factor': 10,
  176. 'state_table': ISO2022JP_ST,
  177. 'char_len_table': ISO2022JP_CHAR_LEN_TABLE,
  178. 'name': "ISO-2022-JP",
  179. 'language': 'Japanese'}
  180. ISO2022KR_CLS = (
  181. 2,0,0,0,0,0,0,0, # 00 - 07
  182. 0,0,0,0,0,0,0,0, # 08 - 0f
  183. 0,0,0,0,0,0,0,0, # 10 - 17
  184. 0,0,0,1,0,0,0,0, # 18 - 1f
  185. 0,0,0,0,3,0,0,0, # 20 - 27
  186. 0,4,0,0,0,0,0,0, # 28 - 2f
  187. 0,0,0,0,0,0,0,0, # 30 - 37
  188. 0,0,0,0,0,0,0,0, # 38 - 3f
  189. 0,0,0,5,0,0,0,0, # 40 - 47
  190. 0,0,0,0,0,0,0,0, # 48 - 4f
  191. 0,0,0,0,0,0,0,0, # 50 - 57
  192. 0,0,0,0,0,0,0,0, # 58 - 5f
  193. 0,0,0,0,0,0,0,0, # 60 - 67
  194. 0,0,0,0,0,0,0,0, # 68 - 6f
  195. 0,0,0,0,0,0,0,0, # 70 - 77
  196. 0,0,0,0,0,0,0,0, # 78 - 7f
  197. 2,2,2,2,2,2,2,2, # 80 - 87
  198. 2,2,2,2,2,2,2,2, # 88 - 8f
  199. 2,2,2,2,2,2,2,2, # 90 - 97
  200. 2,2,2,2,2,2,2,2, # 98 - 9f
  201. 2,2,2,2,2,2,2,2, # a0 - a7
  202. 2,2,2,2,2,2,2,2, # a8 - af
  203. 2,2,2,2,2,2,2,2, # b0 - b7
  204. 2,2,2,2,2,2,2,2, # b8 - bf
  205. 2,2,2,2,2,2,2,2, # c0 - c7
  206. 2,2,2,2,2,2,2,2, # c8 - cf
  207. 2,2,2,2,2,2,2,2, # d0 - d7
  208. 2,2,2,2,2,2,2,2, # d8 - df
  209. 2,2,2,2,2,2,2,2, # e0 - e7
  210. 2,2,2,2,2,2,2,2, # e8 - ef
  211. 2,2,2,2,2,2,2,2, # f0 - f7
  212. 2,2,2,2,2,2,2,2, # f8 - ff
  213. )
  214. ISO2022KR_ST = (
  215. MachineState.START, 3,MachineState.ERROR,MachineState.START,MachineState.START,MachineState.START,MachineState.ERROR,MachineState.ERROR,# 00-07
  216. MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 08-0f
  217. MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 4,MachineState.ERROR,MachineState.ERROR,# 10-17
  218. MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 5,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 18-1f
  219. MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 20-27
  220. )
  221. ISO2022KR_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0)
  222. ISO2022KR_SM_MODEL = {'class_table': ISO2022KR_CLS,
  223. 'class_factor': 6,
  224. 'state_table': ISO2022KR_ST,
  225. 'char_len_table': ISO2022KR_CHAR_LEN_TABLE,
  226. 'name': "ISO-2022-KR",
  227. 'language': 'Korean'}