Path: blob/master/venv/Lib/site-packages/chardet/escsm.py
811 views
######################## BEGIN LICENSE BLOCK ########################1# The Original Code is mozilla.org code.2#3# The Initial Developer of the Original Code is4# Netscape Communications Corporation.5# Portions created by the Initial Developer are Copyright (C) 19986# the Initial Developer. All Rights Reserved.7#8# Contributor(s):9# Mark Pilgrim - port to Python10#11# This library is free software; you can redistribute it and/or12# modify it under the terms of the GNU Lesser General Public13# License as published by the Free Software Foundation; either14# version 2.1 of the License, or (at your option) any later version.15#16# This library is distributed in the hope that it will be useful,17# but WITHOUT ANY WARRANTY; without even the implied warranty of18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU19# Lesser General Public License for more details.20#21# You should have received a copy of the GNU Lesser General Public22# License along with this library; if not, write to the Free Software23# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA24# 02110-1301 USA25######################### END LICENSE BLOCK #########################2627from .enums import MachineState2829HZ_CLS = (301,0,0,0,0,0,0,0, # 00 - 07310,0,0,0,0,0,0,0, # 08 - 0f320,0,0,0,0,0,0,0, # 10 - 17330,0,0,1,0,0,0,0, # 18 - 1f340,0,0,0,0,0,0,0, # 20 - 27350,0,0,0,0,0,0,0, # 28 - 2f360,0,0,0,0,0,0,0, # 30 - 37370,0,0,0,0,0,0,0, # 38 - 3f380,0,0,0,0,0,0,0, # 40 - 47390,0,0,0,0,0,0,0, # 48 - 4f400,0,0,0,0,0,0,0, # 50 - 57410,0,0,0,0,0,0,0, # 58 - 5f420,0,0,0,0,0,0,0, # 60 - 67430,0,0,0,0,0,0,0, # 68 - 6f440,0,0,0,0,0,0,0, # 70 - 77450,0,0,4,0,5,2,0, # 78 - 7f461,1,1,1,1,1,1,1, # 80 - 87471,1,1,1,1,1,1,1, # 88 - 8f481,1,1,1,1,1,1,1, # 90 - 97491,1,1,1,1,1,1,1, # 98 - 9f501,1,1,1,1,1,1,1, # a0 - a7511,1,1,1,1,1,1,1, # a8 - af521,1,1,1,1,1,1,1, # b0 - b7531,1,1,1,1,1,1,1, # b8 - bf541,1,1,1,1,1,1,1, # c0 - c7551,1,1,1,1,1,1,1, # c8 - cf561,1,1,1,1,1,1,1, # d0 - d7571,1,1,1,1,1,1,1, # d8 - df581,1,1,1,1,1,1,1, # e0 - e7591,1,1,1,1,1,1,1, # e8 - ef601,1,1,1,1,1,1,1, # f0 - f7611,1,1,1,1,1,1,1, # f8 - ff62)6364HZ_ST = (65MachineState.START,MachineState.ERROR, 3,MachineState.START,MachineState.START,MachineState.START,MachineState.ERROR,MachineState.ERROR,# 00-0766MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 08-0f67MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.START,MachineState.START, 4,MachineState.ERROR,# 10-17685,MachineState.ERROR, 6,MachineState.ERROR, 5, 5, 4,MachineState.ERROR,# 18-1f694,MachineState.ERROR, 4, 4, 4,MachineState.ERROR, 4,MachineState.ERROR,# 20-27704,MachineState.ITS_ME,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 28-2f71)7273HZ_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0)7475HZ_SM_MODEL = {'class_table': HZ_CLS,76'class_factor': 6,77'state_table': HZ_ST,78'char_len_table': HZ_CHAR_LEN_TABLE,79'name': "HZ-GB-2312",80'language': 'Chinese'}8182ISO2022CN_CLS = (832,0,0,0,0,0,0,0, # 00 - 07840,0,0,0,0,0,0,0, # 08 - 0f850,0,0,0,0,0,0,0, # 10 - 17860,0,0,1,0,0,0,0, # 18 - 1f870,0,0,0,0,0,0,0, # 20 - 27880,3,0,0,0,0,0,0, # 28 - 2f890,0,0,0,0,0,0,0, # 30 - 37900,0,0,0,0,0,0,0, # 38 - 3f910,0,0,4,0,0,0,0, # 40 - 47920,0,0,0,0,0,0,0, # 48 - 4f930,0,0,0,0,0,0,0, # 50 - 57940,0,0,0,0,0,0,0, # 58 - 5f950,0,0,0,0,0,0,0, # 60 - 67960,0,0,0,0,0,0,0, # 68 - 6f970,0,0,0,0,0,0,0, # 70 - 77980,0,0,0,0,0,0,0, # 78 - 7f992,2,2,2,2,2,2,2, # 80 - 871002,2,2,2,2,2,2,2, # 88 - 8f1012,2,2,2,2,2,2,2, # 90 - 971022,2,2,2,2,2,2,2, # 98 - 9f1032,2,2,2,2,2,2,2, # a0 - a71042,2,2,2,2,2,2,2, # a8 - af1052,2,2,2,2,2,2,2, # b0 - b71062,2,2,2,2,2,2,2, # b8 - bf1072,2,2,2,2,2,2,2, # c0 - c71082,2,2,2,2,2,2,2, # c8 - cf1092,2,2,2,2,2,2,2, # d0 - d71102,2,2,2,2,2,2,2, # d8 - df1112,2,2,2,2,2,2,2, # e0 - e71122,2,2,2,2,2,2,2, # e8 - ef1132,2,2,2,2,2,2,2, # f0 - f71142,2,2,2,2,2,2,2, # f8 - ff115)116117ISO2022CN_ST = (118MachineState.START, 3,MachineState.ERROR,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 00-07119MachineState.START,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 08-0f120MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 10-17121MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 4,MachineState.ERROR,# 18-1f122MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 20-271235, 6,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 28-2f124MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 30-37125MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.START,# 38-3f126)127128ISO2022CN_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0, 0, 0, 0)129130ISO2022CN_SM_MODEL = {'class_table': ISO2022CN_CLS,131'class_factor': 9,132'state_table': ISO2022CN_ST,133'char_len_table': ISO2022CN_CHAR_LEN_TABLE,134'name': "ISO-2022-CN",135'language': 'Chinese'}136137ISO2022JP_CLS = (1382,0,0,0,0,0,0,0, # 00 - 071390,0,0,0,0,0,2,2, # 08 - 0f1400,0,0,0,0,0,0,0, # 10 - 171410,0,0,1,0,0,0,0, # 18 - 1f1420,0,0,0,7,0,0,0, # 20 - 271433,0,0,0,0,0,0,0, # 28 - 2f1440,0,0,0,0,0,0,0, # 30 - 371450,0,0,0,0,0,0,0, # 38 - 3f1466,0,4,0,8,0,0,0, # 40 - 471470,9,5,0,0,0,0,0, # 48 - 4f1480,0,0,0,0,0,0,0, # 50 - 571490,0,0,0,0,0,0,0, # 58 - 5f1500,0,0,0,0,0,0,0, # 60 - 671510,0,0,0,0,0,0,0, # 68 - 6f1520,0,0,0,0,0,0,0, # 70 - 771530,0,0,0,0,0,0,0, # 78 - 7f1542,2,2,2,2,2,2,2, # 80 - 871552,2,2,2,2,2,2,2, # 88 - 8f1562,2,2,2,2,2,2,2, # 90 - 971572,2,2,2,2,2,2,2, # 98 - 9f1582,2,2,2,2,2,2,2, # a0 - a71592,2,2,2,2,2,2,2, # a8 - af1602,2,2,2,2,2,2,2, # b0 - b71612,2,2,2,2,2,2,2, # b8 - bf1622,2,2,2,2,2,2,2, # c0 - c71632,2,2,2,2,2,2,2, # c8 - cf1642,2,2,2,2,2,2,2, # d0 - d71652,2,2,2,2,2,2,2, # d8 - df1662,2,2,2,2,2,2,2, # e0 - e71672,2,2,2,2,2,2,2, # e8 - ef1682,2,2,2,2,2,2,2, # f0 - f71692,2,2,2,2,2,2,2, # f8 - ff170)171172ISO2022JP_ST = (173MachineState.START, 3,MachineState.ERROR,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 00-07174MachineState.START,MachineState.START,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 08-0f175MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 10-17176MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,# 18-1f177MachineState.ERROR, 5,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 4,MachineState.ERROR,MachineState.ERROR,# 20-27178MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 6,MachineState.ITS_ME,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,# 28-2f179MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,# 30-37180MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 38-3f181MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.START,MachineState.START,# 40-47182)183184ISO2022JP_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)185186ISO2022JP_SM_MODEL = {'class_table': ISO2022JP_CLS,187'class_factor': 10,188'state_table': ISO2022JP_ST,189'char_len_table': ISO2022JP_CHAR_LEN_TABLE,190'name': "ISO-2022-JP",191'language': 'Japanese'}192193ISO2022KR_CLS = (1942,0,0,0,0,0,0,0, # 00 - 071950,0,0,0,0,0,0,0, # 08 - 0f1960,0,0,0,0,0,0,0, # 10 - 171970,0,0,1,0,0,0,0, # 18 - 1f1980,0,0,0,3,0,0,0, # 20 - 271990,4,0,0,0,0,0,0, # 28 - 2f2000,0,0,0,0,0,0,0, # 30 - 372010,0,0,0,0,0,0,0, # 38 - 3f2020,0,0,5,0,0,0,0, # 40 - 472030,0,0,0,0,0,0,0, # 48 - 4f2040,0,0,0,0,0,0,0, # 50 - 572050,0,0,0,0,0,0,0, # 58 - 5f2060,0,0,0,0,0,0,0, # 60 - 672070,0,0,0,0,0,0,0, # 68 - 6f2080,0,0,0,0,0,0,0, # 70 - 772090,0,0,0,0,0,0,0, # 78 - 7f2102,2,2,2,2,2,2,2, # 80 - 872112,2,2,2,2,2,2,2, # 88 - 8f2122,2,2,2,2,2,2,2, # 90 - 972132,2,2,2,2,2,2,2, # 98 - 9f2142,2,2,2,2,2,2,2, # a0 - a72152,2,2,2,2,2,2,2, # a8 - af2162,2,2,2,2,2,2,2, # b0 - b72172,2,2,2,2,2,2,2, # b8 - bf2182,2,2,2,2,2,2,2, # c0 - c72192,2,2,2,2,2,2,2, # c8 - cf2202,2,2,2,2,2,2,2, # d0 - d72212,2,2,2,2,2,2,2, # d8 - df2222,2,2,2,2,2,2,2, # e0 - e72232,2,2,2,2,2,2,2, # e8 - ef2242,2,2,2,2,2,2,2, # f0 - f72252,2,2,2,2,2,2,2, # f8 - ff226)227228ISO2022KR_ST = (229MachineState.START, 3,MachineState.ERROR,MachineState.START,MachineState.START,MachineState.START,MachineState.ERROR,MachineState.ERROR,# 00-07230MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 08-0f231MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 4,MachineState.ERROR,MachineState.ERROR,# 10-17232MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 5,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 18-1f233MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 20-27234)235236ISO2022KR_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0)237238ISO2022KR_SM_MODEL = {'class_table': ISO2022KR_CLS,239'class_factor': 6,240'state_table': ISO2022KR_ST,241'char_len_table': ISO2022KR_CHAR_LEN_TABLE,242'name': "ISO-2022-KR",243'language': 'Korean'}244245246247248