Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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 

28from .enums import MachineState 

29 

30HZ_CLS = ( 

311,0,0,0,0,0,0,0, # 00 - 07 

320,0,0,0,0,0,0,0, # 08 - 0f 

330,0,0,0,0,0,0,0, # 10 - 17 

340,0,0,1,0,0,0,0, # 18 - 1f 

350,0,0,0,0,0,0,0, # 20 - 27 

360,0,0,0,0,0,0,0, # 28 - 2f 

370,0,0,0,0,0,0,0, # 30 - 37 

380,0,0,0,0,0,0,0, # 38 - 3f 

390,0,0,0,0,0,0,0, # 40 - 47 

400,0,0,0,0,0,0,0, # 48 - 4f 

410,0,0,0,0,0,0,0, # 50 - 57 

420,0,0,0,0,0,0,0, # 58 - 5f 

430,0,0,0,0,0,0,0, # 60 - 67 

440,0,0,0,0,0,0,0, # 68 - 6f 

450,0,0,0,0,0,0,0, # 70 - 77 

460,0,0,4,0,5,2,0, # 78 - 7f 

471,1,1,1,1,1,1,1, # 80 - 87 

481,1,1,1,1,1,1,1, # 88 - 8f 

491,1,1,1,1,1,1,1, # 90 - 97 

501,1,1,1,1,1,1,1, # 98 - 9f 

511,1,1,1,1,1,1,1, # a0 - a7 

521,1,1,1,1,1,1,1, # a8 - af 

531,1,1,1,1,1,1,1, # b0 - b7 

541,1,1,1,1,1,1,1, # b8 - bf 

551,1,1,1,1,1,1,1, # c0 - c7 

561,1,1,1,1,1,1,1, # c8 - cf 

571,1,1,1,1,1,1,1, # d0 - d7 

581,1,1,1,1,1,1,1, # d8 - df 

591,1,1,1,1,1,1,1, # e0 - e7 

601,1,1,1,1,1,1,1, # e8 - ef 

611,1,1,1,1,1,1,1, # f0 - f7 

621,1,1,1,1,1,1,1, # f8 - ff 

63) 

64 

65HZ_ST = ( 

66MachineState.START,MachineState.ERROR, 3,MachineState.START,MachineState.START,MachineState.START,MachineState.ERROR,MachineState.ERROR,# 00-07 

67MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 08-0f 

68MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.START,MachineState.START, 4,MachineState.ERROR,# 10-17 

69 5,MachineState.ERROR, 6,MachineState.ERROR, 5, 5, 4,MachineState.ERROR,# 18-1f 

70 4,MachineState.ERROR, 4, 4, 4,MachineState.ERROR, 4,MachineState.ERROR,# 20-27 

71 4,MachineState.ITS_ME,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 28-2f 

72) 

73 

74HZ_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0) 

75 

76HZ_SM_MODEL = {'class_table': HZ_CLS, 

77 'class_factor': 6, 

78 'state_table': HZ_ST, 

79 'char_len_table': HZ_CHAR_LEN_TABLE, 

80 'name': "HZ-GB-2312", 

81 'language': 'Chinese'} 

82 

83ISO2022CN_CLS = ( 

842,0,0,0,0,0,0,0, # 00 - 07 

850,0,0,0,0,0,0,0, # 08 - 0f 

860,0,0,0,0,0,0,0, # 10 - 17 

870,0,0,1,0,0,0,0, # 18 - 1f 

880,0,0,0,0,0,0,0, # 20 - 27 

890,3,0,0,0,0,0,0, # 28 - 2f 

900,0,0,0,0,0,0,0, # 30 - 37 

910,0,0,0,0,0,0,0, # 38 - 3f 

920,0,0,4,0,0,0,0, # 40 - 47 

930,0,0,0,0,0,0,0, # 48 - 4f 

940,0,0,0,0,0,0,0, # 50 - 57 

950,0,0,0,0,0,0,0, # 58 - 5f 

960,0,0,0,0,0,0,0, # 60 - 67 

970,0,0,0,0,0,0,0, # 68 - 6f 

980,0,0,0,0,0,0,0, # 70 - 77 

990,0,0,0,0,0,0,0, # 78 - 7f 

1002,2,2,2,2,2,2,2, # 80 - 87 

1012,2,2,2,2,2,2,2, # 88 - 8f 

1022,2,2,2,2,2,2,2, # 90 - 97 

1032,2,2,2,2,2,2,2, # 98 - 9f 

1042,2,2,2,2,2,2,2, # a0 - a7 

1052,2,2,2,2,2,2,2, # a8 - af 

1062,2,2,2,2,2,2,2, # b0 - b7 

1072,2,2,2,2,2,2,2, # b8 - bf 

1082,2,2,2,2,2,2,2, # c0 - c7 

1092,2,2,2,2,2,2,2, # c8 - cf 

1102,2,2,2,2,2,2,2, # d0 - d7 

1112,2,2,2,2,2,2,2, # d8 - df 

1122,2,2,2,2,2,2,2, # e0 - e7 

1132,2,2,2,2,2,2,2, # e8 - ef 

1142,2,2,2,2,2,2,2, # f0 - f7 

1152,2,2,2,2,2,2,2, # f8 - ff 

116) 

117 

118ISO2022CN_ST = ( 

119MachineState.START, 3,MachineState.ERROR,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 00-07 

120MachineState.START,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 08-0f 

121MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 10-17 

122MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 4,MachineState.ERROR,# 18-1f 

123MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 20-27 

124 5, 6,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 28-2f 

125MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 30-37 

126MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.START,# 38-3f 

127) 

128 

129ISO2022CN_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0, 0, 0, 0) 

130 

131ISO2022CN_SM_MODEL = {'class_table': ISO2022CN_CLS, 

132 'class_factor': 9, 

133 'state_table': ISO2022CN_ST, 

134 'char_len_table': ISO2022CN_CHAR_LEN_TABLE, 

135 'name': "ISO-2022-CN", 

136 'language': 'Chinese'} 

137 

138ISO2022JP_CLS = ( 

1392,0,0,0,0,0,0,0, # 00 - 07 

1400,0,0,0,0,0,2,2, # 08 - 0f 

1410,0,0,0,0,0,0,0, # 10 - 17 

1420,0,0,1,0,0,0,0, # 18 - 1f 

1430,0,0,0,7,0,0,0, # 20 - 27 

1443,0,0,0,0,0,0,0, # 28 - 2f 

1450,0,0,0,0,0,0,0, # 30 - 37 

1460,0,0,0,0,0,0,0, # 38 - 3f 

1476,0,4,0,8,0,0,0, # 40 - 47 

1480,9,5,0,0,0,0,0, # 48 - 4f 

1490,0,0,0,0,0,0,0, # 50 - 57 

1500,0,0,0,0,0,0,0, # 58 - 5f 

1510,0,0,0,0,0,0,0, # 60 - 67 

1520,0,0,0,0,0,0,0, # 68 - 6f 

1530,0,0,0,0,0,0,0, # 70 - 77 

1540,0,0,0,0,0,0,0, # 78 - 7f 

1552,2,2,2,2,2,2,2, # 80 - 87 

1562,2,2,2,2,2,2,2, # 88 - 8f 

1572,2,2,2,2,2,2,2, # 90 - 97 

1582,2,2,2,2,2,2,2, # 98 - 9f 

1592,2,2,2,2,2,2,2, # a0 - a7 

1602,2,2,2,2,2,2,2, # a8 - af 

1612,2,2,2,2,2,2,2, # b0 - b7 

1622,2,2,2,2,2,2,2, # b8 - bf 

1632,2,2,2,2,2,2,2, # c0 - c7 

1642,2,2,2,2,2,2,2, # c8 - cf 

1652,2,2,2,2,2,2,2, # d0 - d7 

1662,2,2,2,2,2,2,2, # d8 - df 

1672,2,2,2,2,2,2,2, # e0 - e7 

1682,2,2,2,2,2,2,2, # e8 - ef 

1692,2,2,2,2,2,2,2, # f0 - f7 

1702,2,2,2,2,2,2,2, # f8 - ff 

171) 

172 

173ISO2022JP_ST = ( 

174MachineState.START, 3,MachineState.ERROR,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 00-07 

175MachineState.START,MachineState.START,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 08-0f 

176MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 10-17 

177MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,# 18-1f 

178MachineState.ERROR, 5,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 4,MachineState.ERROR,MachineState.ERROR,# 20-27 

179MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 6,MachineState.ITS_ME,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,# 28-2f 

180MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,# 30-37 

181MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 38-3f 

182MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.START,MachineState.START,# 40-47 

183) 

184 

185ISO2022JP_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0) 

186 

187ISO2022JP_SM_MODEL = {'class_table': ISO2022JP_CLS, 

188 'class_factor': 10, 

189 'state_table': ISO2022JP_ST, 

190 'char_len_table': ISO2022JP_CHAR_LEN_TABLE, 

191 'name': "ISO-2022-JP", 

192 'language': 'Japanese'} 

193 

194ISO2022KR_CLS = ( 

1952,0,0,0,0,0,0,0, # 00 - 07 

1960,0,0,0,0,0,0,0, # 08 - 0f 

1970,0,0,0,0,0,0,0, # 10 - 17 

1980,0,0,1,0,0,0,0, # 18 - 1f 

1990,0,0,0,3,0,0,0, # 20 - 27 

2000,4,0,0,0,0,0,0, # 28 - 2f 

2010,0,0,0,0,0,0,0, # 30 - 37 

2020,0,0,0,0,0,0,0, # 38 - 3f 

2030,0,0,5,0,0,0,0, # 40 - 47 

2040,0,0,0,0,0,0,0, # 48 - 4f 

2050,0,0,0,0,0,0,0, # 50 - 57 

2060,0,0,0,0,0,0,0, # 58 - 5f 

2070,0,0,0,0,0,0,0, # 60 - 67 

2080,0,0,0,0,0,0,0, # 68 - 6f 

2090,0,0,0,0,0,0,0, # 70 - 77 

2100,0,0,0,0,0,0,0, # 78 - 7f 

2112,2,2,2,2,2,2,2, # 80 - 87 

2122,2,2,2,2,2,2,2, # 88 - 8f 

2132,2,2,2,2,2,2,2, # 90 - 97 

2142,2,2,2,2,2,2,2, # 98 - 9f 

2152,2,2,2,2,2,2,2, # a0 - a7 

2162,2,2,2,2,2,2,2, # a8 - af 

2172,2,2,2,2,2,2,2, # b0 - b7 

2182,2,2,2,2,2,2,2, # b8 - bf 

2192,2,2,2,2,2,2,2, # c0 - c7 

2202,2,2,2,2,2,2,2, # c8 - cf 

2212,2,2,2,2,2,2,2, # d0 - d7 

2222,2,2,2,2,2,2,2, # d8 - df 

2232,2,2,2,2,2,2,2, # e0 - e7 

2242,2,2,2,2,2,2,2, # e8 - ef 

2252,2,2,2,2,2,2,2, # f0 - f7 

2262,2,2,2,2,2,2,2, # f8 - ff 

227) 

228 

229ISO2022KR_ST = ( 

230MachineState.START, 3,MachineState.ERROR,MachineState.START,MachineState.START,MachineState.START,MachineState.ERROR,MachineState.ERROR,# 00-07 

231MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 08-0f 

232MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 4,MachineState.ERROR,MachineState.ERROR,# 10-17 

233MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 5,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 18-1f 

234MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 20-27 

235) 

236 

237ISO2022KR_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0) 

238 

239ISO2022KR_SM_MODEL = {'class_table': ISO2022KR_CLS, 

240 'class_factor': 6, 

241 'state_table': ISO2022KR_ST, 

242 'char_len_table': ISO2022KR_CHAR_LEN_TABLE, 

243 'name': "ISO-2022-KR", 

244 'language': 'Korean'} 

245 

246