cchardet 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.gitmodules +3 -0
- data/.rubocop.yml +11 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +10 -0
- data/README.md +35 -0
- data/Rakefile +15 -0
- data/cchardet.gemspec +30 -0
- data/ext/cchardet/extconf.rb +26 -0
- data/ext/uchardet/.gitignore +1 -0
- data/ext/uchardet/.gitlab-ci.yml +106 -0
- data/ext/uchardet/AUTHORS +16 -0
- data/ext/uchardet/CMakeLists.txt +74 -0
- data/ext/uchardet/COPYING +1316 -0
- data/ext/uchardet/INSTALL +26 -0
- data/ext/uchardet/README.md +295 -0
- data/ext/uchardet/build-mac/uchardet.cpp +7 -0
- data/ext/uchardet/build-mac/uchardet.xcodeproj/project.pbxproj +543 -0
- data/ext/uchardet/build-mac/uchardet.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/ext/uchardet/build-mac/uchardet.xcodeproj/project.xcworkspace/xcshareddata/uchardet.xccheckout +41 -0
- data/ext/uchardet/build-mac/uchardet.xcodeproj/xcshareddata/xcschemes/uchardet-ios.xcscheme +77 -0
- data/ext/uchardet/build-mac/uchardet.xcodeproj/xcshareddata/xcschemes/uchardet.xcscheme +77 -0
- data/ext/uchardet/doc/CMakeLists.txt +6 -0
- data/ext/uchardet/doc/README.maintainer +59 -0
- data/ext/uchardet/doc/uchardet.1 +18 -0
- data/ext/uchardet/script/BuildLangModel.py +533 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangArabicModel.log +142 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangCroatianModel.log +157 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangCzechModel.log +161 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangDanishModel.log +158 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangEsperantoModel.log +110 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangEstonianModel.log +159 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangFinnishModel.log +156 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangFrenchModel.log +116 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangGermanModel.log +159 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangGreekModel.log +272 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangHungarianModel.log +109 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangIrishModel.log +156 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangItalianModel.log +162 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangLatvianModel.log +162 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangLithuanianModel.log +162 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangMalteseModel.log +147 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangPolishModel.log +154 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangPortugueseModel.log +166 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangRomanianModel.log +153 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangSlovakModel.log +158 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangSloveneModel.log +148 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangSpanishModel.log +109 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangSwedishModel.log +151 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangThaiModel.log +141 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangTurkishModel.log +113 -0
- data/ext/uchardet/script/BuildLangModelLogs/LangVietnameseModel.log +121 -0
- data/ext/uchardet/script/README +63 -0
- data/ext/uchardet/script/charsets/codepoints.py +53 -0
- data/ext/uchardet/script/charsets/db.py +73 -0
- data/ext/uchardet/script/charsets/ibm852.py +72 -0
- data/ext/uchardet/script/charsets/iso-8859-1.py +85 -0
- data/ext/uchardet/script/charsets/iso-8859-10.py +73 -0
- data/ext/uchardet/script/charsets/iso-8859-11.py +77 -0
- data/ext/uchardet/script/charsets/iso-8859-13.py +72 -0
- data/ext/uchardet/script/charsets/iso-8859-15.py +80 -0
- data/ext/uchardet/script/charsets/iso-8859-16.py +83 -0
- data/ext/uchardet/script/charsets/iso-8859-2.py +73 -0
- data/ext/uchardet/script/charsets/iso-8859-3.py +75 -0
- data/ext/uchardet/script/charsets/iso-8859-4.py +73 -0
- data/ext/uchardet/script/charsets/iso-8859-6.py +73 -0
- data/ext/uchardet/script/charsets/iso-8859-7.py +73 -0
- data/ext/uchardet/script/charsets/iso-8859-9.py +76 -0
- data/ext/uchardet/script/charsets/mac-centraleurope.py +72 -0
- data/ext/uchardet/script/charsets/tis-620.py +77 -0
- data/ext/uchardet/script/charsets/viscii.py +72 -0
- data/ext/uchardet/script/charsets/windows-1250.py +75 -0
- data/ext/uchardet/script/charsets/windows-1252.py +76 -0
- data/ext/uchardet/script/charsets/windows-1253.py +72 -0
- data/ext/uchardet/script/charsets/windows-1256.py +75 -0
- data/ext/uchardet/script/charsets/windows-1257.py +72 -0
- data/ext/uchardet/script/charsets/windows-1258.py +72 -0
- data/ext/uchardet/script/debug.sh +9 -0
- data/ext/uchardet/script/header-template.cpp +38 -0
- data/ext/uchardet/script/langs/ar.py +59 -0
- data/ext/uchardet/script/langs/cs.py +80 -0
- data/ext/uchardet/script/langs/da.py +69 -0
- data/ext/uchardet/script/langs/de.py +69 -0
- data/ext/uchardet/script/langs/el.py +55 -0
- data/ext/uchardet/script/langs/eo.py +67 -0
- data/ext/uchardet/script/langs/es.py +69 -0
- data/ext/uchardet/script/langs/et.py +57 -0
- data/ext/uchardet/script/langs/fi.py +60 -0
- data/ext/uchardet/script/langs/fr.py +79 -0
- data/ext/uchardet/script/langs/ga.py +60 -0
- data/ext/uchardet/script/langs/hr.py +59 -0
- data/ext/uchardet/script/langs/hu.py +66 -0
- data/ext/uchardet/script/langs/it.py +56 -0
- data/ext/uchardet/script/langs/lt.py +70 -0
- data/ext/uchardet/script/langs/lv.py +69 -0
- data/ext/uchardet/script/langs/mt.py +80 -0
- data/ext/uchardet/script/langs/pl.py +81 -0
- data/ext/uchardet/script/langs/pt.py +80 -0
- data/ext/uchardet/script/langs/ro.py +65 -0
- data/ext/uchardet/script/langs/sk.py +80 -0
- data/ext/uchardet/script/langs/sl.py +59 -0
- data/ext/uchardet/script/langs/sv.py +56 -0
- data/ext/uchardet/script/langs/th.py +55 -0
- data/ext/uchardet/script/langs/tr.py +67 -0
- data/ext/uchardet/script/langs/vi.py +64 -0
- data/ext/uchardet/script/release.sh +8 -0
- data/ext/uchardet/script/win32.sh +7 -0
- data/ext/uchardet/src/Big5Freq.tab +943 -0
- data/ext/uchardet/src/CMakeLists.txt +160 -0
- data/ext/uchardet/src/CharDistribution.cpp +109 -0
- data/ext/uchardet/src/CharDistribution.h +242 -0
- data/ext/uchardet/src/EUCKRFreq.tab +614 -0
- data/ext/uchardet/src/EUCTWFreq.tab +447 -0
- data/ext/uchardet/src/GB2312Freq.tab +491 -0
- data/ext/uchardet/src/JISFreq.tab +589 -0
- data/ext/uchardet/src/JpCntx.cpp +230 -0
- data/ext/uchardet/src/JpCntx.h +140 -0
- data/ext/uchardet/src/LangModels/LangArabicModel.cpp +267 -0
- data/ext/uchardet/src/LangModels/LangBulgarianModel.cpp +249 -0
- data/ext/uchardet/src/LangModels/LangCroatianModel.cpp +298 -0
- data/ext/uchardet/src/LangModels/LangCzechModel.cpp +285 -0
- data/ext/uchardet/src/LangModels/LangDanishModel.cpp +201 -0
- data/ext/uchardet/src/LangModels/LangEsperantoModel.cpp +142 -0
- data/ext/uchardet/src/LangModels/LangEstonianModel.cpp +268 -0
- data/ext/uchardet/src/LangModels/LangFinnishModel.cpp +297 -0
- data/ext/uchardet/src/LangModels/LangFrenchModel.cpp +209 -0
- data/ext/uchardet/src/LangModels/LangGermanModel.cpp +170 -0
- data/ext/uchardet/src/LangModels/LangGreekModel.cpp +231 -0
- data/ext/uchardet/src/LangModels/LangHebrewModel.cpp +220 -0
- data/ext/uchardet/src/LangModels/LangHungarianModel.cpp +171 -0
- data/ext/uchardet/src/LangModels/LangIrishModel.cpp +234 -0
- data/ext/uchardet/src/LangModels/LangItalianModel.cpp +269 -0
- data/ext/uchardet/src/LangModels/LangLatvianModel.cpp +210 -0
- data/ext/uchardet/src/LangModels/LangLithuanianModel.cpp +209 -0
- data/ext/uchardet/src/LangModels/LangMalteseModel.cpp +138 -0
- data/ext/uchardet/src/LangModels/LangPolishModel.cpp +304 -0
- data/ext/uchardet/src/LangModels/LangPortugueseModel.cpp +241 -0
- data/ext/uchardet/src/LangModels/LangRomanianModel.cpp +236 -0
- data/ext/uchardet/src/LangModels/LangRussianModel.cpp +367 -0
- data/ext/uchardet/src/LangModels/LangSlovakModel.cpp +293 -0
- data/ext/uchardet/src/LangModels/LangSloveneModel.cpp +264 -0
- data/ext/uchardet/src/LangModels/LangSpanishModel.cpp +204 -0
- data/ext/uchardet/src/LangModels/LangSwedishModel.cpp +266 -0
- data/ext/uchardet/src/LangModels/LangThaiModel.cpp +267 -0
- data/ext/uchardet/src/LangModels/LangTurkishModel.cpp +175 -0
- data/ext/uchardet/src/LangModels/LangVietnameseModel.cpp +249 -0
- data/ext/uchardet/src/nsBig5Prober.cpp +88 -0
- data/ext/uchardet/src/nsBig5Prober.h +75 -0
- data/ext/uchardet/src/nsCharSetProber.cpp +125 -0
- data/ext/uchardet/src/nsCharSetProber.h +77 -0
- data/ext/uchardet/src/nsCodingStateMachine.h +105 -0
- data/ext/uchardet/src/nsEUCJPProber.cpp +99 -0
- data/ext/uchardet/src/nsEUCJPProber.h +79 -0
- data/ext/uchardet/src/nsEUCKRProber.cpp +91 -0
- data/ext/uchardet/src/nsEUCKRProber.h +81 -0
- data/ext/uchardet/src/nsEUCTWProber.cpp +91 -0
- data/ext/uchardet/src/nsEUCTWProber.h +75 -0
- data/ext/uchardet/src/nsEscCharsetProber.cpp +101 -0
- data/ext/uchardet/src/nsEscCharsetProber.h +70 -0
- data/ext/uchardet/src/nsEscSM.cpp +267 -0
- data/ext/uchardet/src/nsGB2312Prober.cpp +96 -0
- data/ext/uchardet/src/nsGB2312Prober.h +77 -0
- data/ext/uchardet/src/nsHebrewProber.cpp +194 -0
- data/ext/uchardet/src/nsHebrewProber.h +177 -0
- data/ext/uchardet/src/nsLatin1Prober.cpp +182 -0
- data/ext/uchardet/src/nsLatin1Prober.h +73 -0
- data/ext/uchardet/src/nsMBCSGroupProber.cpp +242 -0
- data/ext/uchardet/src/nsMBCSGroupProber.h +81 -0
- data/ext/uchardet/src/nsMBCSSM.cpp +513 -0
- data/ext/uchardet/src/nsPkgInt.h +89 -0
- data/ext/uchardet/src/nsSBCSGroupProber.cpp +343 -0
- data/ext/uchardet/src/nsSBCSGroupProber.h +71 -0
- data/ext/uchardet/src/nsSBCharSetProber.cpp +160 -0
- data/ext/uchardet/src/nsSBCharSetProber.h +258 -0
- data/ext/uchardet/src/nsSJISProber.cpp +98 -0
- data/ext/uchardet/src/nsSJISProber.h +81 -0
- data/ext/uchardet/src/nsUTF8Prober.cpp +87 -0
- data/ext/uchardet/src/nsUTF8Prober.h +66 -0
- data/ext/uchardet/src/nsUniversalDetector.cpp +339 -0
- data/ext/uchardet/src/nsUniversalDetector.h +91 -0
- data/ext/uchardet/src/nscore.h +59 -0
- data/ext/uchardet/src/prmem.h +49 -0
- data/ext/uchardet/src/symbols.cmake +41 -0
- data/ext/uchardet/src/tools/CMakeLists.txt +23 -0
- data/ext/uchardet/src/tools/uchardet.cpp +254 -0
- data/ext/uchardet/src/uchardet.cpp +274 -0
- data/ext/uchardet/src/uchardet.h +136 -0
- data/ext/uchardet/test/CMakeLists.txt +47 -0
- data/ext/uchardet/test/ar/iso-8859-6.txt +3 -0
- data/ext/uchardet/test/ar/utf-8.txt +3 -0
- data/ext/uchardet/test/ar/windows-1256.txt +3 -0
- data/ext/uchardet/test/bg/windows-1251.txt +3 -0
- data/ext/uchardet/test/cs/ibm852.txt +4 -0
- data/ext/uchardet/test/cs/iso-8859-2.txt +4 -0
- data/ext/uchardet/test/cs/mac-centraleurope.txt +4 -0
- data/ext/uchardet/test/cs/utf-8.txt +4 -0
- data/ext/uchardet/test/cs/windows-1250.txt +4 -0
- data/ext/uchardet/test/da/iso-8859-1.txt +7 -0
- data/ext/uchardet/test/da/iso-8859-15.txt +10 -0
- data/ext/uchardet/test/da/utf-8.txt +10 -0
- data/ext/uchardet/test/da/windows-1252.txt +10 -0
- data/ext/uchardet/test/de/iso-8859-1.txt +11 -0
- data/ext/uchardet/test/de/windows-1252.txt +11 -0
- data/ext/uchardet/test/el/iso-8859-7.txt +3 -0
- data/ext/uchardet/test/el/utf-8.txt +3 -0
- data/ext/uchardet/test/el/windows-1253.txt +5 -0
- data/ext/uchardet/test/en/ascii.txt +4 -0
- data/ext/uchardet/test/eo/iso-8859-3.txt +7 -0
- data/ext/uchardet/test/es/iso-8859-1.txt +5 -0
- data/ext/uchardet/test/es/iso-8859-15.txt +5 -0
- data/ext/uchardet/test/es/utf-8.txt +5 -0
- data/ext/uchardet/test/es/windows-1252.txt +5 -0
- data/ext/uchardet/test/et/iso-8859-13.txt +6 -0
- data/ext/uchardet/test/et/iso-8859-15.txt +6 -0
- data/ext/uchardet/test/et/iso-8859-4.txt +6 -0
- data/ext/uchardet/test/et/utf-8.txt +6 -0
- data/ext/uchardet/test/et/windows-1252.txt +6 -0
- data/ext/uchardet/test/et/windows-1257.txt +6 -0
- data/ext/uchardet/test/fi/iso-8859-1.txt +8 -0
- data/ext/uchardet/test/fi/utf-8.txt +8 -0
- data/ext/uchardet/test/fr/iso-8859-1.txt +5 -0
- data/ext/uchardet/test/fr/iso-8859-15.txt +16 -0
- data/ext/uchardet/test/fr/utf-16.be +0 -0
- data/ext/uchardet/test/fr/utf-32.le +0 -0
- data/ext/uchardet/test/fr/utf-8.txt +14 -0
- data/ext/uchardet/test/fr/windows-1252.txt +3 -0
- data/ext/uchardet/test/ga/iso-8859-1.txt +6 -0
- data/ext/uchardet/test/ga/utf-8.txt +6 -0
- data/ext/uchardet/test/ga/windows-1252.txt +6 -0
- data/ext/uchardet/test/he/iso-8859-8.txt +2 -0
- data/ext/uchardet/test/he/utf-8.txt +3 -0
- data/ext/uchardet/test/he/windows-1255.txt +1 -0
- data/ext/uchardet/test/hr/ibm852.txt +4 -0
- data/ext/uchardet/test/hr/iso-8859-13.txt +4 -0
- data/ext/uchardet/test/hr/iso-8859-16.txt +4 -0
- data/ext/uchardet/test/hr/iso-8859-2.txt +4 -0
- data/ext/uchardet/test/hr/mac-centraleurope.txt +4 -0
- data/ext/uchardet/test/hr/utf-8.txt +4 -0
- data/ext/uchardet/test/hr/windows-1250.txt +4 -0
- data/ext/uchardet/test/hu/iso-8859-2.txt +3 -0
- data/ext/uchardet/test/hu/windows-1250.txt +1 -0
- data/ext/uchardet/test/it/iso-8859-1.txt +18 -0
- data/ext/uchardet/test/it/utf-8.txt +18 -0
- data/ext/uchardet/test/ja/euc-jp.txt +10 -0
- data/ext/uchardet/test/ja/iso-2022-jp.txt +8 -0
- data/ext/uchardet/test/ja/shift_jis.txt +1 -0
- data/ext/uchardet/test/ja/utf-16be.txt +0 -0
- data/ext/uchardet/test/ja/utf-16le.txt +0 -0
- data/ext/uchardet/test/ja/utf-8.txt +9 -0
- data/ext/uchardet/test/ko/iso-2022-kr.txt +8 -0
- data/ext/uchardet/test/ko/uhc.smi +16 -0
- data/ext/uchardet/test/ko/utf-16.le +0 -0
- data/ext/uchardet/test/ko/utf-32.be +0 -0
- data/ext/uchardet/test/ko/utf-8.txt +3 -0
- data/ext/uchardet/test/lt/iso-8859-10.txt +3 -0
- data/ext/uchardet/test/lt/iso-8859-13.txt +3 -0
- data/ext/uchardet/test/lt/iso-8859-4.txt +3 -0
- data/ext/uchardet/test/lt/utf-8.txt +3 -0
- data/ext/uchardet/test/lv/iso-8859-10.txt +6 -0
- data/ext/uchardet/test/lv/iso-8859-13.txt +6 -0
- data/ext/uchardet/test/lv/iso-8859-4.txt +6 -0
- data/ext/uchardet/test/lv/utf-8.txt +6 -0
- data/ext/uchardet/test/mt/iso-8859-3.txt +4 -0
- data/ext/uchardet/test/mt/utf-8.txt +4 -0
- data/ext/uchardet/test/pl/ibm852.txt +3 -0
- data/ext/uchardet/test/pl/iso-8859-13.txt +3 -0
- data/ext/uchardet/test/pl/iso-8859-16.txt +3 -0
- data/ext/uchardet/test/pl/iso-8859-2.txt +3 -0
- data/ext/uchardet/test/pl/mac-centraleurope.txt +3 -0
- data/ext/uchardet/test/pl/utf-8.txt +3 -0
- data/ext/uchardet/test/pl/windows-1250.txt +3 -0
- data/ext/uchardet/test/pt/iso-8859-1.txt +6 -0
- data/ext/uchardet/test/pt/utf-8.txt +6 -0
- data/ext/uchardet/test/ro/ibm852.txt +9 -0
- data/ext/uchardet/test/ro/iso-8859-16.txt +9 -0
- data/ext/uchardet/test/ro/utf-8.txt +9 -0
- data/ext/uchardet/test/ro/windows-1250.txt +9 -0
- data/ext/uchardet/test/ru/ibm855.txt +5 -0
- data/ext/uchardet/test/ru/ibm866.txt +11 -0
- data/ext/uchardet/test/ru/iso-8859-5.txt +3 -0
- data/ext/uchardet/test/ru/koi8-r.txt +1 -0
- data/ext/uchardet/test/ru/mac-cyrillic.txt +9 -0
- data/ext/uchardet/test/ru/windows-1251.txt +4 -0
- data/ext/uchardet/test/sk/ibm852.txt +3 -0
- data/ext/uchardet/test/sk/iso-8859-2.txt +3 -0
- data/ext/uchardet/test/sk/mac-centraleurope.txt +3 -0
- data/ext/uchardet/test/sk/utf-8.txt +3 -0
- data/ext/uchardet/test/sk/windows-1250.txt +3 -0
- data/ext/uchardet/test/sl/ibm852.txt +9 -0
- data/ext/uchardet/test/sl/iso-8859-16.txt +9 -0
- data/ext/uchardet/test/sl/iso-8859-2.txt +9 -0
- data/ext/uchardet/test/sl/mac-centraleurope.txt +9 -0
- data/ext/uchardet/test/sl/utf-8.txt +9 -0
- data/ext/uchardet/test/sl/windows-1250.txt +9 -0
- data/ext/uchardet/test/sv/iso-8859-1.txt +10 -0
- data/ext/uchardet/test/sv/utf-8.txt +10 -0
- data/ext/uchardet/test/sv/windows-1252.txt +10 -0
- data/ext/uchardet/test/th/iso-8859-11.txt +5 -0
- data/ext/uchardet/test/th/tis-620.txt +5 -0
- data/ext/uchardet/test/th/utf-8.txt +1 -0
- data/ext/uchardet/test/tr/iso-8859-3.txt +13 -0
- data/ext/uchardet/test/tr/iso-8859-9.txt +13 -0
- data/ext/uchardet/test/uchardet-tests.c +130 -0
- data/ext/uchardet/test/vi/utf-8.txt +4 -0
- data/ext/uchardet/test/vi/viscii.txt +4 -0
- data/ext/uchardet/test/vi/windows-1258.txt +4 -0
- data/ext/uchardet/test/zh/big5.txt +1 -0
- data/ext/uchardet/test/zh/euc-tw.txt +1 -0
- data/ext/uchardet/test/zh/gb18030.txt +1 -0
- data/ext/uchardet/test/zh/utf-8.txt +1 -0
- data/ext/uchardet/uchardet.doap +51 -0
- data/ext/uchardet/uchardet.pc.in +10 -0
- data/lib/cchardet.rb +56 -0
- data/lib/cchardet/lib_finder.rb +32 -0
- data/lib/cchardet/version.rb +5 -0
- metadata +362 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
2
|
+
/* ***** BEGIN LICENSE BLOCK *****
|
|
3
|
+
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
4
|
+
*
|
|
5
|
+
* The contents of this file are subject to the Mozilla Public License Version
|
|
6
|
+
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
7
|
+
* the License. You may obtain a copy of the License at
|
|
8
|
+
* http://www.mozilla.org/MPL/
|
|
9
|
+
*
|
|
10
|
+
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
11
|
+
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
12
|
+
* for the specific language governing rights and limitations under the
|
|
13
|
+
* License.
|
|
14
|
+
*
|
|
15
|
+
* The Original Code is Mozilla Universal charset detector code.
|
|
16
|
+
*
|
|
17
|
+
* The Initial Developer of the Original Code is
|
|
18
|
+
* Netscape Communications Corporation.
|
|
19
|
+
* Portions created by the Initial Developer are Copyright (C) 2001
|
|
20
|
+
* the Initial Developer. All Rights Reserved.
|
|
21
|
+
*
|
|
22
|
+
* Contributor(s):
|
|
23
|
+
* Shy Shalom <shooshX@gmail.com>
|
|
24
|
+
*
|
|
25
|
+
* Alternatively, the contents of this file may be used under the terms of
|
|
26
|
+
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
27
|
+
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
28
|
+
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
29
|
+
* of those above. If you wish to allow use of your version of this file only
|
|
30
|
+
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
31
|
+
* use your version of this file under the terms of the MPL, indicate your
|
|
32
|
+
* decision by deleting the provisions above and replace them with the notice
|
|
33
|
+
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
34
|
+
* the provisions above, a recipient may use your version of this file under
|
|
35
|
+
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
36
|
+
*
|
|
37
|
+
* ***** END LICENSE BLOCK ***** */
|
|
38
|
+
|
|
39
|
+
#ifndef nsLatin1Prober_h__
|
|
40
|
+
#define nsLatin1Prober_h__
|
|
41
|
+
|
|
42
|
+
#include <cstddef>
|
|
43
|
+
|
|
44
|
+
#include "nsCharSetProber.h"
|
|
45
|
+
|
|
46
|
+
#define FREQ_CAT_NUM 4
|
|
47
|
+
|
|
48
|
+
class nsLatin1Prober: public nsCharSetProber {
|
|
49
|
+
public:
|
|
50
|
+
nsLatin1Prober(void){Reset();}
|
|
51
|
+
virtual ~nsLatin1Prober(void){}
|
|
52
|
+
nsProbingState HandleData(const char* aBuf, PRUint32 aLen);
|
|
53
|
+
const char* GetCharSetName() {return "WINDOWS-1252";}
|
|
54
|
+
const char* GetLanguage() {return NULL;}
|
|
55
|
+
nsProbingState GetState(void) {return mState;}
|
|
56
|
+
void Reset(void);
|
|
57
|
+
float GetConfidence(void);
|
|
58
|
+
void SetOpion() {}
|
|
59
|
+
|
|
60
|
+
#ifdef DEBUG_chardet
|
|
61
|
+
virtual void DumpStatus();
|
|
62
|
+
#endif
|
|
63
|
+
|
|
64
|
+
protected:
|
|
65
|
+
|
|
66
|
+
nsProbingState mState;
|
|
67
|
+
char mLastCharClass;
|
|
68
|
+
PRUint32 mFreqCounter[FREQ_CAT_NUM];
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
#endif /* nsLatin1Prober_h__ */
|
|
73
|
+
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
2
|
+
/* ***** BEGIN LICENSE BLOCK *****
|
|
3
|
+
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
4
|
+
*
|
|
5
|
+
* The contents of this file are subject to the Mozilla Public License Version
|
|
6
|
+
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
7
|
+
* the License. You may obtain a copy of the License at
|
|
8
|
+
* http://www.mozilla.org/MPL/
|
|
9
|
+
*
|
|
10
|
+
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
11
|
+
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
12
|
+
* for the specific language governing rights and limitations under the
|
|
13
|
+
* License.
|
|
14
|
+
*
|
|
15
|
+
* The Original Code is Mozilla Universal charset detector code.
|
|
16
|
+
*
|
|
17
|
+
* The Initial Developer of the Original Code is
|
|
18
|
+
* Netscape Communications Corporation.
|
|
19
|
+
* Portions created by the Initial Developer are Copyright (C) 2001
|
|
20
|
+
* the Initial Developer. All Rights Reserved.
|
|
21
|
+
*
|
|
22
|
+
* Contributor(s):
|
|
23
|
+
* Shy Shalom <shooshX@gmail.com>
|
|
24
|
+
* Proofpoint, Inc.
|
|
25
|
+
*
|
|
26
|
+
* Alternatively, the contents of this file may be used under the terms of
|
|
27
|
+
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
28
|
+
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
29
|
+
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
30
|
+
* of those above. If you wish to allow use of your version of this file only
|
|
31
|
+
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
32
|
+
* use your version of this file under the terms of the MPL, indicate your
|
|
33
|
+
* decision by deleting the provisions above and replace them with the notice
|
|
34
|
+
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
35
|
+
* the provisions above, a recipient may use your version of this file under
|
|
36
|
+
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
37
|
+
*
|
|
38
|
+
* ***** END LICENSE BLOCK ***** */
|
|
39
|
+
#include <stdio.h>
|
|
40
|
+
|
|
41
|
+
#include "nsMBCSGroupProber.h"
|
|
42
|
+
#include "nsUniversalDetector.h"
|
|
43
|
+
|
|
44
|
+
#if defined(DEBUG_chardet) || defined(DEBUG_jgmyers)
|
|
45
|
+
const char *ProberName[] =
|
|
46
|
+
{
|
|
47
|
+
"UTF-8",
|
|
48
|
+
"SJIS",
|
|
49
|
+
"EUC-JP",
|
|
50
|
+
"GB18030",
|
|
51
|
+
"EUC-KR",
|
|
52
|
+
"Big5",
|
|
53
|
+
"EUC-TW",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
#endif
|
|
57
|
+
|
|
58
|
+
nsMBCSGroupProber::nsMBCSGroupProber(PRUint32 aLanguageFilter)
|
|
59
|
+
{
|
|
60
|
+
for (PRUint32 i = 0; i < NUM_OF_PROBERS; i++)
|
|
61
|
+
mProbers[i] = nsnull;
|
|
62
|
+
|
|
63
|
+
mProbers[0] = new nsUTF8Prober();
|
|
64
|
+
if (aLanguageFilter & NS_FILTER_JAPANESE)
|
|
65
|
+
{
|
|
66
|
+
mProbers[1] = new nsSJISProber(aLanguageFilter == NS_FILTER_JAPANESE);
|
|
67
|
+
mProbers[2] = new nsEUCJPProber(aLanguageFilter == NS_FILTER_JAPANESE);
|
|
68
|
+
}
|
|
69
|
+
if (aLanguageFilter & NS_FILTER_CHINESE_SIMPLIFIED)
|
|
70
|
+
mProbers[3] = new nsGB18030Prober(aLanguageFilter == NS_FILTER_CHINESE_SIMPLIFIED);
|
|
71
|
+
if (aLanguageFilter & NS_FILTER_KOREAN)
|
|
72
|
+
mProbers[4] = new nsEUCKRProber(aLanguageFilter == NS_FILTER_KOREAN);
|
|
73
|
+
if (aLanguageFilter & NS_FILTER_CHINESE_TRADITIONAL)
|
|
74
|
+
{
|
|
75
|
+
mProbers[5] = new nsBig5Prober(aLanguageFilter == NS_FILTER_CHINESE_TRADITIONAL);
|
|
76
|
+
mProbers[6] = new nsEUCTWProber(aLanguageFilter == NS_FILTER_CHINESE_TRADITIONAL);
|
|
77
|
+
}
|
|
78
|
+
Reset();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
nsMBCSGroupProber::~nsMBCSGroupProber()
|
|
82
|
+
{
|
|
83
|
+
for (PRUint32 i = 0; i < NUM_OF_PROBERS; i++)
|
|
84
|
+
{
|
|
85
|
+
delete mProbers[i];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const char* nsMBCSGroupProber::GetCharSetName()
|
|
90
|
+
{
|
|
91
|
+
if (mBestGuess == -1)
|
|
92
|
+
{
|
|
93
|
+
GetConfidence();
|
|
94
|
+
if (mBestGuess == -1)
|
|
95
|
+
mBestGuess = 0;
|
|
96
|
+
}
|
|
97
|
+
return mProbers[mBestGuess]->GetCharSetName();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const char* nsMBCSGroupProber::GetLanguage(void)
|
|
101
|
+
{
|
|
102
|
+
if (mBestGuess == -1)
|
|
103
|
+
{
|
|
104
|
+
GetConfidence();
|
|
105
|
+
}
|
|
106
|
+
if (mBestGuess == -1)
|
|
107
|
+
return NULL;
|
|
108
|
+
else
|
|
109
|
+
return mProbers[mBestGuess]->GetLanguage();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
void nsMBCSGroupProber::Reset(void)
|
|
113
|
+
{
|
|
114
|
+
mActiveNum = 0;
|
|
115
|
+
for (PRUint32 i = 0; i < NUM_OF_PROBERS; i++)
|
|
116
|
+
{
|
|
117
|
+
if (mProbers[i])
|
|
118
|
+
{
|
|
119
|
+
mProbers[i]->Reset();
|
|
120
|
+
mIsActive[i] = PR_TRUE;
|
|
121
|
+
++mActiveNum;
|
|
122
|
+
}
|
|
123
|
+
else
|
|
124
|
+
mIsActive[i] = PR_FALSE;
|
|
125
|
+
}
|
|
126
|
+
mBestGuess = -1;
|
|
127
|
+
mState = eDetecting;
|
|
128
|
+
mKeepNext = 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
nsProbingState nsMBCSGroupProber::HandleData(const char* aBuf, PRUint32 aLen)
|
|
132
|
+
{
|
|
133
|
+
nsProbingState st;
|
|
134
|
+
PRUint32 start = 0;
|
|
135
|
+
PRUint32 keepNext = mKeepNext;
|
|
136
|
+
|
|
137
|
+
//do filtering to reduce load to probers
|
|
138
|
+
for (PRUint32 pos = 0; pos < aLen; ++pos)
|
|
139
|
+
{
|
|
140
|
+
if (aBuf[pos] & 0x80)
|
|
141
|
+
{
|
|
142
|
+
if (!keepNext)
|
|
143
|
+
start = pos;
|
|
144
|
+
keepNext = 2;
|
|
145
|
+
}
|
|
146
|
+
else if (keepNext)
|
|
147
|
+
{
|
|
148
|
+
if (--keepNext == 0)
|
|
149
|
+
{
|
|
150
|
+
for (PRUint32 i = 0; i < NUM_OF_PROBERS; i++)
|
|
151
|
+
{
|
|
152
|
+
if (!mIsActive[i])
|
|
153
|
+
continue;
|
|
154
|
+
st = mProbers[i]->HandleData(aBuf + start, pos + 1 - start);
|
|
155
|
+
if (st == eFoundIt)
|
|
156
|
+
{
|
|
157
|
+
mBestGuess = i;
|
|
158
|
+
mState = eFoundIt;
|
|
159
|
+
return mState;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (keepNext) {
|
|
167
|
+
for (PRUint32 i = 0; i < NUM_OF_PROBERS; i++)
|
|
168
|
+
{
|
|
169
|
+
if (!mIsActive[i])
|
|
170
|
+
continue;
|
|
171
|
+
st = mProbers[i]->HandleData(aBuf + start, aLen - start);
|
|
172
|
+
if (st == eFoundIt)
|
|
173
|
+
{
|
|
174
|
+
mBestGuess = i;
|
|
175
|
+
mState = eFoundIt;
|
|
176
|
+
return mState;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
mKeepNext = keepNext;
|
|
181
|
+
|
|
182
|
+
return mState;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
float nsMBCSGroupProber::GetConfidence(void)
|
|
186
|
+
{
|
|
187
|
+
PRUint32 i;
|
|
188
|
+
float bestConf = 0.0, cf;
|
|
189
|
+
|
|
190
|
+
switch (mState)
|
|
191
|
+
{
|
|
192
|
+
case eFoundIt:
|
|
193
|
+
return (float)0.99;
|
|
194
|
+
case eNotMe:
|
|
195
|
+
return (float)0.01;
|
|
196
|
+
default:
|
|
197
|
+
for (i = 0; i < NUM_OF_PROBERS; i++)
|
|
198
|
+
{
|
|
199
|
+
if (!mIsActive[i])
|
|
200
|
+
continue;
|
|
201
|
+
cf = mProbers[i]->GetConfidence();
|
|
202
|
+
if (bestConf < cf)
|
|
203
|
+
{
|
|
204
|
+
bestConf = cf;
|
|
205
|
+
mBestGuess = i;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return bestConf;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
#ifdef DEBUG_chardet
|
|
213
|
+
void nsMBCSGroupProber::DumpStatus()
|
|
214
|
+
{
|
|
215
|
+
PRUint32 i;
|
|
216
|
+
float cf;
|
|
217
|
+
|
|
218
|
+
GetConfidence();
|
|
219
|
+
for (i = 0; i < NUM_OF_PROBERS; i++)
|
|
220
|
+
{
|
|
221
|
+
if (!mIsActive[i])
|
|
222
|
+
printf(" MBCS inactive: [%s] (confidence is too low).\r\n", ProberName[i]);
|
|
223
|
+
else
|
|
224
|
+
{
|
|
225
|
+
cf = mProbers[i]->GetConfidence();
|
|
226
|
+
printf(" MBCS %1.3f: [%s]\r\n", cf, ProberName[i]);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
#endif
|
|
231
|
+
|
|
232
|
+
#ifdef DEBUG_jgmyers
|
|
233
|
+
void nsMBCSGroupProber::GetDetectorState(nsUniversalDetector::DetectorState (&states)[nsUniversalDetector::NumDetectors], PRUint32 &offset)
|
|
234
|
+
{
|
|
235
|
+
for (PRUint32 i = 0; i < NUM_OF_PROBERS; ++i) {
|
|
236
|
+
states[offset].name = ProberName[i];
|
|
237
|
+
states[offset].isActive = mIsActive[i];
|
|
238
|
+
states[offset].confidence = mIsActive[i] ? mProbers[i]->GetConfidence() : 0.0;
|
|
239
|
+
++offset;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
#endif /* DEBUG_jgmyers */
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
2
|
+
/* ***** BEGIN LICENSE BLOCK *****
|
|
3
|
+
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
4
|
+
*
|
|
5
|
+
* The contents of this file are subject to the Mozilla Public License Version
|
|
6
|
+
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
7
|
+
* the License. You may obtain a copy of the License at
|
|
8
|
+
* http://www.mozilla.org/MPL/
|
|
9
|
+
*
|
|
10
|
+
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
11
|
+
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
12
|
+
* for the specific language governing rights and limitations under the
|
|
13
|
+
* License.
|
|
14
|
+
*
|
|
15
|
+
* The Original Code is mozilla.org code.
|
|
16
|
+
*
|
|
17
|
+
* The Initial Developer of the Original Code is
|
|
18
|
+
* Netscape Communications Corporation.
|
|
19
|
+
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
20
|
+
* the Initial Developer. All Rights Reserved.
|
|
21
|
+
*
|
|
22
|
+
* Contributor(s):
|
|
23
|
+
* Proofpoint, Inc.
|
|
24
|
+
*
|
|
25
|
+
* Alternatively, the contents of this file may be used under the terms of
|
|
26
|
+
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
27
|
+
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
28
|
+
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
29
|
+
* of those above. If you wish to allow use of your version of this file only
|
|
30
|
+
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
31
|
+
* use your version of this file under the terms of the MPL, indicate your
|
|
32
|
+
* decision by deleting the provisions above and replace them with the notice
|
|
33
|
+
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
34
|
+
* the provisions above, a recipient may use your version of this file under
|
|
35
|
+
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
36
|
+
*
|
|
37
|
+
* ***** END LICENSE BLOCK ***** */
|
|
38
|
+
|
|
39
|
+
#ifndef nsMBCSGroupProber_h__
|
|
40
|
+
#define nsMBCSGroupProber_h__
|
|
41
|
+
|
|
42
|
+
#include "nsSJISProber.h"
|
|
43
|
+
#include "nsUTF8Prober.h"
|
|
44
|
+
#include "nsEUCJPProber.h"
|
|
45
|
+
#include "nsGB2312Prober.h"
|
|
46
|
+
#include "nsEUCKRProber.h"
|
|
47
|
+
#include "nsBig5Prober.h"
|
|
48
|
+
#include "nsEUCTWProber.h"
|
|
49
|
+
|
|
50
|
+
#define NUM_OF_PROBERS 7
|
|
51
|
+
|
|
52
|
+
class nsMBCSGroupProber: public nsCharSetProber {
|
|
53
|
+
public:
|
|
54
|
+
nsMBCSGroupProber(PRUint32 aLanguageFilter);
|
|
55
|
+
virtual ~nsMBCSGroupProber();
|
|
56
|
+
nsProbingState HandleData(const char* aBuf, PRUint32 aLen);
|
|
57
|
+
const char* GetCharSetName();
|
|
58
|
+
const char* GetLanguage();
|
|
59
|
+
nsProbingState GetState(void) {return mState;}
|
|
60
|
+
void Reset(void);
|
|
61
|
+
float GetConfidence(void);
|
|
62
|
+
void SetOpion() {}
|
|
63
|
+
|
|
64
|
+
#ifdef DEBUG_chardet
|
|
65
|
+
void DumpStatus();
|
|
66
|
+
#endif
|
|
67
|
+
#ifdef DEBUG_jgmyers
|
|
68
|
+
void GetDetectorState(nsUniversalDetector::DetectorState (&states)[nsUniversalDetector::NumDetectors], PRUint32 &offset);
|
|
69
|
+
#endif
|
|
70
|
+
|
|
71
|
+
protected:
|
|
72
|
+
nsProbingState mState;
|
|
73
|
+
nsCharSetProber* mProbers[NUM_OF_PROBERS];
|
|
74
|
+
PRBool mIsActive[NUM_OF_PROBERS];
|
|
75
|
+
PRInt32 mBestGuess;
|
|
76
|
+
PRUint32 mActiveNum;
|
|
77
|
+
PRUint32 mKeepNext;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
#endif /* nsMBCSGroupProber_h__ */
|
|
81
|
+
|
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
2
|
+
/* ***** BEGIN LICENSE BLOCK *****
|
|
3
|
+
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
4
|
+
*
|
|
5
|
+
* The contents of this file are subject to the Mozilla Public License Version
|
|
6
|
+
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
7
|
+
* the License. You may obtain a copy of the License at
|
|
8
|
+
* http://www.mozilla.org/MPL/
|
|
9
|
+
*
|
|
10
|
+
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
11
|
+
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
12
|
+
* for the specific language governing rights and limitations under the
|
|
13
|
+
* License.
|
|
14
|
+
*
|
|
15
|
+
* The Original Code is mozilla.org code.
|
|
16
|
+
*
|
|
17
|
+
* The Initial Developer of the Original Code is
|
|
18
|
+
* Netscape Communications Corporation.
|
|
19
|
+
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
20
|
+
* the Initial Developer. All Rights Reserved.
|
|
21
|
+
*
|
|
22
|
+
* Contributor(s):
|
|
23
|
+
*
|
|
24
|
+
* Alternatively, the contents of this file may be used under the terms of
|
|
25
|
+
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
26
|
+
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
27
|
+
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
28
|
+
* of those above. If you wish to allow use of your version of this file only
|
|
29
|
+
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
30
|
+
* use your version of this file under the terms of the MPL, indicate your
|
|
31
|
+
* decision by deleting the provisions above and replace them with the notice
|
|
32
|
+
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
33
|
+
* the provisions above, a recipient may use your version of this file under
|
|
34
|
+
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
35
|
+
*
|
|
36
|
+
* ***** END LICENSE BLOCK ***** */
|
|
37
|
+
#include "nsCodingStateMachine.h"
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
Modification from frank tang's original work:
|
|
41
|
+
. 0x00 is allowed as a legal character. Since some web pages contains this char in
|
|
42
|
+
text stream.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
// BIG5
|
|
46
|
+
|
|
47
|
+
static const PRUint32 BIG5_cls [ 256 / 8 ] = {
|
|
48
|
+
//PCK4BITS(0,1,1,1,1,1,1,1), // 00 - 07
|
|
49
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 00 - 07 //allow 0x00 as legal value
|
|
50
|
+
PCK4BITS(1,1,1,1,1,1,0,0), // 08 - 0f
|
|
51
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 10 - 17
|
|
52
|
+
PCK4BITS(1,1,1,0,1,1,1,1), // 18 - 1f
|
|
53
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 20 - 27
|
|
54
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 28 - 2f
|
|
55
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 30 - 37
|
|
56
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 38 - 3f
|
|
57
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 40 - 47
|
|
58
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 48 - 4f
|
|
59
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 50 - 57
|
|
60
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 58 - 5f
|
|
61
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 60 - 67
|
|
62
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 68 - 6f
|
|
63
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 70 - 77
|
|
64
|
+
PCK4BITS(2,2,2,2,2,2,2,1), // 78 - 7f
|
|
65
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 80 - 87
|
|
66
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 88 - 8f
|
|
67
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 90 - 97
|
|
68
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 98 - 9f
|
|
69
|
+
PCK4BITS(4,3,3,3,3,3,3,3), // a0 - a7
|
|
70
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // a8 - af
|
|
71
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // b0 - b7
|
|
72
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // b8 - bf
|
|
73
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // c0 - c7
|
|
74
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // c8 - cf
|
|
75
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // d0 - d7
|
|
76
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // d8 - df
|
|
77
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // e0 - e7
|
|
78
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // e8 - ef
|
|
79
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // f0 - f7
|
|
80
|
+
PCK4BITS(3,3,3,3,3,3,3,0) // f8 - ff
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
static const PRUint32 BIG5_st [ 3] = {
|
|
85
|
+
PCK4BITS(eError,eStart,eStart, 3,eError,eError,eError,eError),//00-07
|
|
86
|
+
PCK4BITS(eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError),//08-0f
|
|
87
|
+
PCK4BITS(eError,eStart,eStart,eStart,eStart,eStart,eStart,eStart) //10-17
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
static const PRUint32 Big5CharLenTable[] = {0, 1, 1, 2, 0};
|
|
91
|
+
|
|
92
|
+
SMModel const Big5SMModel = {
|
|
93
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, BIG5_cls },
|
|
94
|
+
5,
|
|
95
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, BIG5_st },
|
|
96
|
+
Big5CharLenTable,
|
|
97
|
+
"BIG5",
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
static const PRUint32 EUCJP_cls [ 256 / 8 ] = {
|
|
101
|
+
//PCK4BITS(5,4,4,4,4,4,4,4), // 00 - 07
|
|
102
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 00 - 07
|
|
103
|
+
PCK4BITS(4,4,4,4,4,4,5,5), // 08 - 0f
|
|
104
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 10 - 17
|
|
105
|
+
PCK4BITS(4,4,4,5,4,4,4,4), // 18 - 1f
|
|
106
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 20 - 27
|
|
107
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 28 - 2f
|
|
108
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 30 - 37
|
|
109
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 38 - 3f
|
|
110
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 40 - 47
|
|
111
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 48 - 4f
|
|
112
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 50 - 57
|
|
113
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 58 - 5f
|
|
114
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 60 - 67
|
|
115
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 68 - 6f
|
|
116
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 70 - 77
|
|
117
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 78 - 7f
|
|
118
|
+
PCK4BITS(5,5,5,5,5,5,5,5), // 80 - 87
|
|
119
|
+
PCK4BITS(5,5,5,5,5,5,1,3), // 88 - 8f
|
|
120
|
+
PCK4BITS(5,5,5,5,5,5,5,5), // 90 - 97
|
|
121
|
+
PCK4BITS(5,5,5,5,5,5,5,5), // 98 - 9f
|
|
122
|
+
PCK4BITS(5,2,2,2,2,2,2,2), // a0 - a7
|
|
123
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // a8 - af
|
|
124
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7
|
|
125
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf
|
|
126
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7
|
|
127
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // c8 - cf
|
|
128
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7
|
|
129
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df
|
|
130
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // e0 - e7
|
|
131
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // e8 - ef
|
|
132
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // f0 - f7
|
|
133
|
+
PCK4BITS(0,0,0,0,0,0,0,5) // f8 - ff
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
static const PRUint32 EUCJP_st [ 5] = {
|
|
138
|
+
PCK4BITS( 3, 4, 3, 5,eStart,eError,eError,eError),//00-07
|
|
139
|
+
PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f
|
|
140
|
+
PCK4BITS(eItsMe,eItsMe,eStart,eError,eStart,eError,eError,eError),//10-17
|
|
141
|
+
PCK4BITS(eError,eError,eStart,eError,eError,eError, 3,eError),//18-1f
|
|
142
|
+
PCK4BITS( 3,eError,eError,eError,eStart,eStart,eStart,eStart) //20-27
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
static const PRUint32 EUCJPCharLenTable[] = {2, 2, 2, 3, 1, 0};
|
|
146
|
+
|
|
147
|
+
const SMModel EUCJPSMModel = {
|
|
148
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCJP_cls },
|
|
149
|
+
6,
|
|
150
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCJP_st },
|
|
151
|
+
EUCJPCharLenTable,
|
|
152
|
+
"EUC-JP",
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
static const PRUint32 EUCKR_cls [ 256 / 8 ] = {
|
|
156
|
+
//PCK4BITS(0,1,1,1,1,1,1,1), // 00 - 07
|
|
157
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 00 - 07
|
|
158
|
+
PCK4BITS(1,1,1,1,1,1,0,0), // 08 - 0f
|
|
159
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 10 - 17
|
|
160
|
+
PCK4BITS(1,1,1,0,1,1,1,1), // 18 - 1f
|
|
161
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 20 - 27
|
|
162
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 28 - 2f
|
|
163
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 30 - 37
|
|
164
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 38 - 3f
|
|
165
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 40 - 47
|
|
166
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 48 - 4f
|
|
167
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 50 - 57
|
|
168
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 58 - 5f
|
|
169
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 60 - 67
|
|
170
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 68 - 6f
|
|
171
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 70 - 77
|
|
172
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 78 - 7f
|
|
173
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 80 - 87
|
|
174
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 88 - 8f
|
|
175
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 90 - 97
|
|
176
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 98 - 9f
|
|
177
|
+
PCK4BITS(0,2,2,2,2,2,2,2), // a0 - a7
|
|
178
|
+
PCK4BITS(2,2,2,2,2,3,3,3), // a8 - af
|
|
179
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7
|
|
180
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf
|
|
181
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7
|
|
182
|
+
PCK4BITS(2,3,2,2,2,2,2,2), // c8 - cf
|
|
183
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7
|
|
184
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df
|
|
185
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // e0 - e7
|
|
186
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // e8 - ef
|
|
187
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // f0 - f7
|
|
188
|
+
PCK4BITS(2,2,2,2,2,2,2,0) // f8 - ff
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
static const PRUint32 EUCKR_st [ 2] = {
|
|
193
|
+
PCK4BITS(eError,eStart, 3,eError,eError,eError,eError,eError),//00-07
|
|
194
|
+
PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart,eStart) //08-0f
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
static const PRUint32 EUCKRCharLenTable[] = {0, 1, 2, 0};
|
|
198
|
+
|
|
199
|
+
const SMModel EUCKRSMModel = {
|
|
200
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCKR_cls },
|
|
201
|
+
4,
|
|
202
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCKR_st },
|
|
203
|
+
EUCKRCharLenTable,
|
|
204
|
+
"EUC-KR",
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
static const PRUint32 EUCTW_cls [ 256 / 8 ] = {
|
|
208
|
+
//PCK4BITS(0,2,2,2,2,2,2,2), // 00 - 07
|
|
209
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 00 - 07
|
|
210
|
+
PCK4BITS(2,2,2,2,2,2,0,0), // 08 - 0f
|
|
211
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 10 - 17
|
|
212
|
+
PCK4BITS(2,2,2,0,2,2,2,2), // 18 - 1f
|
|
213
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 20 - 27
|
|
214
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 28 - 2f
|
|
215
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 30 - 37
|
|
216
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 38 - 3f
|
|
217
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 40 - 47
|
|
218
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 48 - 4f
|
|
219
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 50 - 57
|
|
220
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 58 - 5f
|
|
221
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 60 - 67
|
|
222
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 68 - 6f
|
|
223
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 70 - 77
|
|
224
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 78 - 7f
|
|
225
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 80 - 87
|
|
226
|
+
PCK4BITS(0,0,0,0,0,0,6,0), // 88 - 8f
|
|
227
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 90 - 97
|
|
228
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 98 - 9f
|
|
229
|
+
PCK4BITS(0,3,4,4,4,4,4,4), // a0 - a7
|
|
230
|
+
PCK4BITS(5,5,1,1,1,1,1,1), // a8 - af
|
|
231
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // b0 - b7
|
|
232
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // b8 - bf
|
|
233
|
+
PCK4BITS(1,1,3,1,3,3,3,3), // c0 - c7
|
|
234
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // c8 - cf
|
|
235
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // d0 - d7
|
|
236
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // d8 - df
|
|
237
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // e0 - e7
|
|
238
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // e8 - ef
|
|
239
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // f0 - f7
|
|
240
|
+
PCK4BITS(3,3,3,3,3,3,3,0) // f8 - ff
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
static const PRUint32 EUCTW_st [ 6] = {
|
|
245
|
+
PCK4BITS(eError,eError,eStart, 3, 3, 3, 4,eError),//00-07
|
|
246
|
+
PCK4BITS(eError,eError,eError,eError,eError,eError,eItsMe,eItsMe),//08-0f
|
|
247
|
+
PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eStart,eError),//10-17
|
|
248
|
+
PCK4BITS(eStart,eStart,eStart,eError,eError,eError,eError,eError),//18-1f
|
|
249
|
+
PCK4BITS( 5,eError,eError,eError,eStart,eError,eStart,eStart),//20-27
|
|
250
|
+
PCK4BITS(eStart,eError,eStart,eStart,eStart,eStart,eStart,eStart) //28-2f
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
static const PRUint32 EUCTWCharLenTable[] = {0, 0, 1, 2, 2, 2, 3};
|
|
254
|
+
|
|
255
|
+
const SMModel EUCTWSMModel = {
|
|
256
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCTW_cls },
|
|
257
|
+
7,
|
|
258
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCTW_st },
|
|
259
|
+
EUCTWCharLenTable,
|
|
260
|
+
"EUC-TW",
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
/* obsolete GB2312 by GB18030
|
|
264
|
+
static PRUint32 GB2312_cls [ 256 / 8 ] = {
|
|
265
|
+
//PCK4BITS(0,1,1,1,1,1,1,1), // 00 - 07
|
|
266
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 00 - 07
|
|
267
|
+
PCK4BITS(1,1,1,1,1,1,0,0), // 08 - 0f
|
|
268
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 10 - 17
|
|
269
|
+
PCK4BITS(1,1,1,0,1,1,1,1), // 18 - 1f
|
|
270
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 20 - 27
|
|
271
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 28 - 2f
|
|
272
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 30 - 37
|
|
273
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 38 - 3f
|
|
274
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 40 - 47
|
|
275
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 48 - 4f
|
|
276
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 50 - 57
|
|
277
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 58 - 5f
|
|
278
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 60 - 67
|
|
279
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 68 - 6f
|
|
280
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 70 - 77
|
|
281
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 78 - 7f
|
|
282
|
+
PCK4BITS(1,0,0,0,0,0,0,0), // 80 - 87
|
|
283
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 88 - 8f
|
|
284
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 90 - 97
|
|
285
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 98 - 9f
|
|
286
|
+
PCK4BITS(0,2,2,2,2,2,2,2), // a0 - a7
|
|
287
|
+
PCK4BITS(2,2,3,3,3,3,3,3), // a8 - af
|
|
288
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7
|
|
289
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf
|
|
290
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7
|
|
291
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // c8 - cf
|
|
292
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7
|
|
293
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df
|
|
294
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // e0 - e7
|
|
295
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // e8 - ef
|
|
296
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // f0 - f7
|
|
297
|
+
PCK4BITS(2,2,2,2,2,2,2,0) // f8 - ff
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
static PRUint32 GB2312_st [ 2] = {
|
|
302
|
+
PCK4BITS(eError,eStart, 3,eError,eError,eError,eError,eError),//00-07
|
|
303
|
+
PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart,eStart) //08-0f
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
static const PRUint32 GB2312CharLenTable[] = {0, 1, 2, 0};
|
|
307
|
+
|
|
308
|
+
SMModel GB2312SMModel = {
|
|
309
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, GB2312_cls },
|
|
310
|
+
4,
|
|
311
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, GB2312_st },
|
|
312
|
+
GB2312CharLenTable,
|
|
313
|
+
"GB2312",
|
|
314
|
+
};
|
|
315
|
+
*/
|
|
316
|
+
|
|
317
|
+
// the following state machine data was created by perl script in
|
|
318
|
+
// intl/chardet/tools. It should be the same as in PSM detector.
|
|
319
|
+
static const PRUint32 GB18030_cls [ 256 / 8 ] = {
|
|
320
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 00 - 07
|
|
321
|
+
PCK4BITS(1,1,1,1,1,1,0,0), // 08 - 0f
|
|
322
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 10 - 17
|
|
323
|
+
PCK4BITS(1,1,1,0,1,1,1,1), // 18 - 1f
|
|
324
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 20 - 27
|
|
325
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 28 - 2f
|
|
326
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // 30 - 37
|
|
327
|
+
PCK4BITS(3,3,1,1,1,1,1,1), // 38 - 3f
|
|
328
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 40 - 47
|
|
329
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 48 - 4f
|
|
330
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 50 - 57
|
|
331
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 58 - 5f
|
|
332
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 60 - 67
|
|
333
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 68 - 6f
|
|
334
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 70 - 77
|
|
335
|
+
PCK4BITS(2,2,2,2,2,2,2,4), // 78 - 7f
|
|
336
|
+
PCK4BITS(5,6,6,6,6,6,6,6), // 80 - 87
|
|
337
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // 88 - 8f
|
|
338
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // 90 - 97
|
|
339
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // 98 - 9f
|
|
340
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // a0 - a7
|
|
341
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // a8 - af
|
|
342
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // b0 - b7
|
|
343
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // b8 - bf
|
|
344
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // c0 - c7
|
|
345
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // c8 - cf
|
|
346
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // d0 - d7
|
|
347
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // d8 - df
|
|
348
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // e0 - e7
|
|
349
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // e8 - ef
|
|
350
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // f0 - f7
|
|
351
|
+
PCK4BITS(6,6,6,6,6,6,6,0) // f8 - ff
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
static const PRUint32 GB18030_st [ 6] = {
|
|
356
|
+
PCK4BITS(eError,eStart,eStart,eStart,eStart,eStart, 3,eError),//00-07
|
|
357
|
+
PCK4BITS(eError,eError,eError,eError,eError,eError,eItsMe,eItsMe),//08-0f
|
|
358
|
+
PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart),//10-17
|
|
359
|
+
PCK4BITS( 4,eError,eStart,eStart,eError,eError,eError,eError),//18-1f
|
|
360
|
+
PCK4BITS(eError,eError, 5,eError,eError,eError,eItsMe,eError),//20-27
|
|
361
|
+
PCK4BITS(eError,eError,eStart,eStart,eStart,eStart,eStart,eStart) //28-2f
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
// To be accurate, the length of class 6 can be either 2 or 4.
|
|
365
|
+
// But it is not necessary to discriminate between the two since
|
|
366
|
+
// it is used for frequency analysis only, and we are validing
|
|
367
|
+
// each code range there as well. So it is safe to set it to be
|
|
368
|
+
// 2 here.
|
|
369
|
+
static const PRUint32 GB18030CharLenTable[] = {0, 1, 1, 1, 1, 1, 2};
|
|
370
|
+
|
|
371
|
+
const SMModel GB18030SMModel = {
|
|
372
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, GB18030_cls },
|
|
373
|
+
7,
|
|
374
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, GB18030_st },
|
|
375
|
+
GB18030CharLenTable,
|
|
376
|
+
"GB18030",
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
// sjis
|
|
380
|
+
|
|
381
|
+
static const PRUint32 SJIS_cls [ 256 / 8 ] = {
|
|
382
|
+
//PCK4BITS(0,1,1,1,1,1,1,1), // 00 - 07
|
|
383
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 00 - 07
|
|
384
|
+
PCK4BITS(1,1,1,1,1,1,0,0), // 08 - 0f
|
|
385
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 10 - 17
|
|
386
|
+
PCK4BITS(1,1,1,0,1,1,1,1), // 18 - 1f
|
|
387
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 20 - 27
|
|
388
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 28 - 2f
|
|
389
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 30 - 37
|
|
390
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 38 - 3f
|
|
391
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 40 - 47
|
|
392
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 48 - 4f
|
|
393
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 50 - 57
|
|
394
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 58 - 5f
|
|
395
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 60 - 67
|
|
396
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 68 - 6f
|
|
397
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 70 - 77
|
|
398
|
+
PCK4BITS(2,2,2,2,2,2,2,1), // 78 - 7f
|
|
399
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // 80 - 87
|
|
400
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // 88 - 8f
|
|
401
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // 90 - 97
|
|
402
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // 98 - 9f
|
|
403
|
+
//0xa0 is illegal in sjis encoding, but some pages does
|
|
404
|
+
//contain such byte. We need to be more error forgiven.
|
|
405
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // a0 - a7
|
|
406
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // a8 - af
|
|
407
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7
|
|
408
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf
|
|
409
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7
|
|
410
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // c8 - cf
|
|
411
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7
|
|
412
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df
|
|
413
|
+
PCK4BITS(3,3,3,3,3,3,3,3), // e0 - e7
|
|
414
|
+
PCK4BITS(3,3,3,3,3,4,4,4), // e8 - ef
|
|
415
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // f0 - f7
|
|
416
|
+
PCK4BITS(4,4,4,4,4,0,0,0) // f8 - ff
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
static const PRUint32 SJIS_st [ 3] = {
|
|
421
|
+
PCK4BITS(eError,eStart,eStart, 3,eError,eError,eError,eError),//00-07
|
|
422
|
+
PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f
|
|
423
|
+
PCK4BITS(eItsMe,eItsMe,eError,eError,eStart,eStart,eStart,eStart) //10-17
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
static const PRUint32 SJISCharLenTable[] = {0, 1, 1, 2, 0, 0};
|
|
427
|
+
|
|
428
|
+
const SMModel SJISSMModel = {
|
|
429
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, SJIS_cls },
|
|
430
|
+
6,
|
|
431
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, SJIS_st },
|
|
432
|
+
SJISCharLenTable,
|
|
433
|
+
"SHIFT_JIS",
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
static const PRUint32 UTF8_cls [ 256 / 8 ] = {
|
|
438
|
+
//PCK4BITS(0,1,1,1,1,1,1,1), // 00 - 07
|
|
439
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 00 - 07 //allow 0x00 as a legal value
|
|
440
|
+
PCK4BITS(1,1,1,1,1,1,0,0), // 08 - 0f
|
|
441
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 10 - 17
|
|
442
|
+
PCK4BITS(1,1,1,0,1,1,1,1), // 18 - 1f
|
|
443
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 20 - 27
|
|
444
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 28 - 2f
|
|
445
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 30 - 37
|
|
446
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 38 - 3f
|
|
447
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 40 - 47
|
|
448
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 48 - 4f
|
|
449
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 50 - 57
|
|
450
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 58 - 5f
|
|
451
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 60 - 67
|
|
452
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 68 - 6f
|
|
453
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 70 - 77
|
|
454
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 78 - 7f
|
|
455
|
+
PCK4BITS(2,2,2,2,3,3,3,3), // 80 - 87
|
|
456
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 88 - 8f
|
|
457
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 90 - 97
|
|
458
|
+
PCK4BITS(4,4,4,4,4,4,4,4), // 98 - 9f
|
|
459
|
+
PCK4BITS(5,5,5,5,5,5,5,5), // a0 - a7
|
|
460
|
+
PCK4BITS(5,5,5,5,5,5,5,5), // a8 - af
|
|
461
|
+
PCK4BITS(5,5,5,5,5,5,5,5), // b0 - b7
|
|
462
|
+
PCK4BITS(5,5,5,5,5,5,5,5), // b8 - bf
|
|
463
|
+
PCK4BITS(0,0,6,6,6,6,6,6), // c0 - c7
|
|
464
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // c8 - cf
|
|
465
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // d0 - d7
|
|
466
|
+
PCK4BITS(6,6,6,6,6,6,6,6), // d8 - df
|
|
467
|
+
PCK4BITS(7,8,8,8,8,8,8,8), // e0 - e7
|
|
468
|
+
PCK4BITS(8,8,8,8,8,9,8,8), // e8 - ef
|
|
469
|
+
PCK4BITS(10,11,11,11,11,11,11,11), // f0 - f7
|
|
470
|
+
PCK4BITS(12,13,13,13,14,15,0,0) // f8 - ff
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
static const PRUint32 UTF8_st [ 26] = {
|
|
475
|
+
PCK4BITS(eError,eStart,eError,eError,eError,eError, 12, 10),//00-07
|
|
476
|
+
PCK4BITS( 9, 11, 8, 7, 6, 5, 4, 3),//08-0f
|
|
477
|
+
PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//10-17
|
|
478
|
+
PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//18-1f
|
|
479
|
+
PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe),//20-27
|
|
480
|
+
PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe),//28-2f
|
|
481
|
+
PCK4BITS(eError,eError, 5, 5, 5, 5,eError,eError),//30-37
|
|
482
|
+
PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//38-3f
|
|
483
|
+
PCK4BITS(eError,eError,eError, 5, 5, 5,eError,eError),//40-47
|
|
484
|
+
PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//48-4f
|
|
485
|
+
PCK4BITS(eError,eError, 7, 7, 7, 7,eError,eError),//50-57
|
|
486
|
+
PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//58-5f
|
|
487
|
+
PCK4BITS(eError,eError,eError,eError, 7, 7,eError,eError),//60-67
|
|
488
|
+
PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//68-6f
|
|
489
|
+
PCK4BITS(eError,eError, 9, 9, 9, 9,eError,eError),//70-77
|
|
490
|
+
PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//78-7f
|
|
491
|
+
PCK4BITS(eError,eError,eError,eError,eError, 9,eError,eError),//80-87
|
|
492
|
+
PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//88-8f
|
|
493
|
+
PCK4BITS(eError,eError, 12, 12, 12, 12,eError,eError),//90-97
|
|
494
|
+
PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//98-9f
|
|
495
|
+
PCK4BITS(eError,eError,eError,eError,eError, 12,eError,eError),//a0-a7
|
|
496
|
+
PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//a8-af
|
|
497
|
+
PCK4BITS(eError,eError, 12, 12, 12,eError,eError,eError),//b0-b7
|
|
498
|
+
PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//b8-bf
|
|
499
|
+
PCK4BITS(eError,eError,eStart,eStart,eStart,eStart,eError,eError),//c0-c7
|
|
500
|
+
PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError) //c8-cf
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
static const PRUint32 UTF8CharLenTable[] = {0, 1, 0, 0, 0, 0, 2, 3,
|
|
504
|
+
3, 3, 4, 4, 5, 5, 6, 6 };
|
|
505
|
+
|
|
506
|
+
const SMModel UTF8SMModel = {
|
|
507
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, UTF8_cls },
|
|
508
|
+
16,
|
|
509
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, UTF8_st },
|
|
510
|
+
UTF8CharLenTable,
|
|
511
|
+
"UTF-8",
|
|
512
|
+
};
|
|
513
|
+
|