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,70 @@
|
|
|
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
|
+
|
|
38
|
+
#ifndef nsEscCharSetProber_h__
|
|
39
|
+
#define nsEscCharSetProber_h__
|
|
40
|
+
|
|
41
|
+
#include <cstddef>
|
|
42
|
+
|
|
43
|
+
#include "nsCharSetProber.h"
|
|
44
|
+
#include "nsCodingStateMachine.h"
|
|
45
|
+
|
|
46
|
+
#define NUM_OF_ESC_CHARSETS 4
|
|
47
|
+
|
|
48
|
+
class nsEscCharSetProber: public nsCharSetProber {
|
|
49
|
+
public:
|
|
50
|
+
nsEscCharSetProber(PRUint32 aLanguageFilter);
|
|
51
|
+
virtual ~nsEscCharSetProber(void);
|
|
52
|
+
nsProbingState HandleData(const char* aBuf, PRUint32 aLen);
|
|
53
|
+
const char* GetCharSetName() {return mDetectedCharset;}
|
|
54
|
+
const char* GetLanguage() {return NULL;}
|
|
55
|
+
nsProbingState GetState(void) {return mState;}
|
|
56
|
+
void Reset(void);
|
|
57
|
+
float GetConfidence(void){return (float)0.99;}
|
|
58
|
+
void SetOpion() {}
|
|
59
|
+
|
|
60
|
+
protected:
|
|
61
|
+
void GetDistribution(PRUint32 aCharLen, const char* aStr);
|
|
62
|
+
|
|
63
|
+
nsCodingStateMachine* mCodingSM[NUM_OF_ESC_CHARSETS] ;
|
|
64
|
+
PRUint32 mActiveSM;
|
|
65
|
+
nsProbingState mState;
|
|
66
|
+
const char * mDetectedCharset;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
#endif /* nsEscCharSetProber_h__ */
|
|
70
|
+
|
|
@@ -0,0 +1,267 @@
|
|
|
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
|
+
static const PRUint32 HZ_cls[ 256 / 8 ] = {
|
|
40
|
+
PCK4BITS(1,0,0,0,0,0,0,0), // 00 - 07
|
|
41
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 08 - 0f
|
|
42
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 10 - 17
|
|
43
|
+
PCK4BITS(0,0,0,1,0,0,0,0), // 18 - 1f
|
|
44
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 20 - 27
|
|
45
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 28 - 2f
|
|
46
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 30 - 37
|
|
47
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 38 - 3f
|
|
48
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 40 - 47
|
|
49
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 48 - 4f
|
|
50
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 50 - 57
|
|
51
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 58 - 5f
|
|
52
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 60 - 67
|
|
53
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 68 - 6f
|
|
54
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 70 - 77
|
|
55
|
+
PCK4BITS(0,0,0,4,0,5,2,0), // 78 - 7f
|
|
56
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 80 - 87
|
|
57
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 88 - 8f
|
|
58
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 90 - 97
|
|
59
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // 98 - 9f
|
|
60
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // a0 - a7
|
|
61
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // a8 - af
|
|
62
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // b0 - b7
|
|
63
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // b8 - bf
|
|
64
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // c0 - c7
|
|
65
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // c8 - cf
|
|
66
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // d0 - d7
|
|
67
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // d8 - df
|
|
68
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // e0 - e7
|
|
69
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // e8 - ef
|
|
70
|
+
PCK4BITS(1,1,1,1,1,1,1,1), // f0 - f7
|
|
71
|
+
PCK4BITS(1,1,1,1,1,1,1,1) // f8 - ff
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
static const PRUint32 HZ_st [ 6] = {
|
|
76
|
+
PCK4BITS(eStart,eError, 3,eStart,eStart,eStart,eError,eError),//00-07
|
|
77
|
+
PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f
|
|
78
|
+
PCK4BITS(eItsMe,eItsMe,eError,eError,eStart,eStart, 4,eError),//10-17
|
|
79
|
+
PCK4BITS( 5,eError, 6,eError, 5, 5, 4,eError),//18-1f
|
|
80
|
+
PCK4BITS( 4,eError, 4, 4, 4,eError, 4,eError),//20-27
|
|
81
|
+
PCK4BITS( 4,eItsMe,eStart,eStart,eStart,eStart,eStart,eStart) //28-2f
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
static const PRUint32 HZCharLenTable[] = {0, 0, 0, 0, 0, 0};
|
|
85
|
+
|
|
86
|
+
const SMModel HZSMModel = {
|
|
87
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, HZ_cls },
|
|
88
|
+
6,
|
|
89
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, HZ_st },
|
|
90
|
+
HZCharLenTable,
|
|
91
|
+
"HZ-GB-2312",
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
static const PRUint32 ISO2022CN_cls [ 256 / 8 ] = {
|
|
96
|
+
PCK4BITS(2,0,0,0,0,0,0,0), // 00 - 07
|
|
97
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 08 - 0f
|
|
98
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 10 - 17
|
|
99
|
+
PCK4BITS(0,0,0,1,0,0,0,0), // 18 - 1f
|
|
100
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 20 - 27
|
|
101
|
+
PCK4BITS(0,3,0,0,0,0,0,0), // 28 - 2f
|
|
102
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 30 - 37
|
|
103
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 38 - 3f
|
|
104
|
+
PCK4BITS(0,0,0,4,0,0,0,0), // 40 - 47
|
|
105
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 48 - 4f
|
|
106
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 50 - 57
|
|
107
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 58 - 5f
|
|
108
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 60 - 67
|
|
109
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 68 - 6f
|
|
110
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 70 - 77
|
|
111
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 78 - 7f
|
|
112
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 80 - 87
|
|
113
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 88 - 8f
|
|
114
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 90 - 97
|
|
115
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 98 - 9f
|
|
116
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // a0 - a7
|
|
117
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // a8 - af
|
|
118
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7
|
|
119
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf
|
|
120
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7
|
|
121
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // c8 - cf
|
|
122
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7
|
|
123
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df
|
|
124
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // e0 - e7
|
|
125
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // e8 - ef
|
|
126
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // f0 - f7
|
|
127
|
+
PCK4BITS(2,2,2,2,2,2,2,2) // f8 - ff
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
static const PRUint32 ISO2022CN_st [ 8] = {
|
|
132
|
+
PCK4BITS(eStart, 3,eError,eStart,eStart,eStart,eStart,eStart),//00-07
|
|
133
|
+
PCK4BITS(eStart,eError,eError,eError,eError,eError,eError,eError),//08-0f
|
|
134
|
+
PCK4BITS(eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe),//10-17
|
|
135
|
+
PCK4BITS(eItsMe,eItsMe,eItsMe,eError,eError,eError, 4,eError),//18-1f
|
|
136
|
+
PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//20-27
|
|
137
|
+
PCK4BITS( 5, 6,eError,eError,eError,eError,eError,eError),//28-2f
|
|
138
|
+
PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//30-37
|
|
139
|
+
PCK4BITS(eError,eError,eError,eError,eError,eItsMe,eError,eStart) //38-3f
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
static const PRUint32 ISO2022CNCharLenTable[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
143
|
+
|
|
144
|
+
const SMModel ISO2022CNSMModel = {
|
|
145
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022CN_cls },
|
|
146
|
+
9,
|
|
147
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022CN_st },
|
|
148
|
+
ISO2022CNCharLenTable,
|
|
149
|
+
"ISO-2022-CN",
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
static const PRUint32 ISO2022JP_cls [ 256 / 8 ] = {
|
|
153
|
+
PCK4BITS(2,0,0,0,0,0,0,0), // 00 - 07
|
|
154
|
+
PCK4BITS(0,0,0,0,0,0,2,2), // 08 - 0f
|
|
155
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 10 - 17
|
|
156
|
+
PCK4BITS(0,0,0,1,0,0,0,0), // 18 - 1f
|
|
157
|
+
PCK4BITS(0,0,0,0,7,0,0,0), // 20 - 27
|
|
158
|
+
PCK4BITS(3,0,0,0,0,0,0,0), // 28 - 2f
|
|
159
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 30 - 37
|
|
160
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 38 - 3f
|
|
161
|
+
PCK4BITS(6,0,4,0,8,0,0,0), // 40 - 47
|
|
162
|
+
PCK4BITS(0,9,5,0,0,0,0,0), // 48 - 4f
|
|
163
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 50 - 57
|
|
164
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 58 - 5f
|
|
165
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 60 - 67
|
|
166
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 68 - 6f
|
|
167
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 70 - 77
|
|
168
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 78 - 7f
|
|
169
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 80 - 87
|
|
170
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 88 - 8f
|
|
171
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 90 - 97
|
|
172
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 98 - 9f
|
|
173
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // a0 - a7
|
|
174
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // a8 - af
|
|
175
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7
|
|
176
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf
|
|
177
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7
|
|
178
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // c8 - cf
|
|
179
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7
|
|
180
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df
|
|
181
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // e0 - e7
|
|
182
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // e8 - ef
|
|
183
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // f0 - f7
|
|
184
|
+
PCK4BITS(2,2,2,2,2,2,2,2) // f8 - ff
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
static const PRUint32 ISO2022JP_st [ 9] = {
|
|
189
|
+
PCK4BITS(eStart, 3,eError,eStart,eStart,eStart,eStart,eStart),//00-07
|
|
190
|
+
PCK4BITS(eStart,eStart,eError,eError,eError,eError,eError,eError),//08-0f
|
|
191
|
+
PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//10-17
|
|
192
|
+
PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError),//18-1f
|
|
193
|
+
PCK4BITS(eError, 5,eError,eError,eError, 4,eError,eError),//20-27
|
|
194
|
+
PCK4BITS(eError,eError,eError, 6,eItsMe,eError,eItsMe,eError),//28-2f
|
|
195
|
+
PCK4BITS(eError,eError,eError,eError,eError,eError,eItsMe,eItsMe),//30-37
|
|
196
|
+
PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//38-3f
|
|
197
|
+
PCK4BITS(eError,eError,eError,eError,eItsMe,eError,eStart,eStart) //40-47
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/* XXX: I needed to complete the 2 last classes for this CharLenTable
|
|
201
|
+
* but I did it a bit randomly. Cf. bug 101030.
|
|
202
|
+
* Let's check this piece of code again later when I understand it
|
|
203
|
+
* better. */
|
|
204
|
+
static const PRUint32 ISO2022JPCharLenTable[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
205
|
+
|
|
206
|
+
const SMModel ISO2022JPSMModel = {
|
|
207
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022JP_cls },
|
|
208
|
+
10,
|
|
209
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022JP_st },
|
|
210
|
+
ISO2022JPCharLenTable,
|
|
211
|
+
"ISO-2022-JP",
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
static const PRUint32 ISO2022KR_cls [ 256 / 8 ] = {
|
|
215
|
+
PCK4BITS(2,0,0,0,0,0,0,0), // 00 - 07
|
|
216
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 08 - 0f
|
|
217
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 10 - 17
|
|
218
|
+
PCK4BITS(0,0,0,1,0,0,0,0), // 18 - 1f
|
|
219
|
+
PCK4BITS(0,0,0,0,3,0,0,0), // 20 - 27
|
|
220
|
+
PCK4BITS(0,4,0,0,0,0,0,0), // 28 - 2f
|
|
221
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 30 - 37
|
|
222
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 38 - 3f
|
|
223
|
+
PCK4BITS(0,0,0,5,0,0,0,0), // 40 - 47
|
|
224
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 48 - 4f
|
|
225
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 50 - 57
|
|
226
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 58 - 5f
|
|
227
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 60 - 67
|
|
228
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 68 - 6f
|
|
229
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 70 - 77
|
|
230
|
+
PCK4BITS(0,0,0,0,0,0,0,0), // 78 - 7f
|
|
231
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 80 - 87
|
|
232
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 88 - 8f
|
|
233
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 90 - 97
|
|
234
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // 98 - 9f
|
|
235
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // a0 - a7
|
|
236
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // a8 - af
|
|
237
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7
|
|
238
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf
|
|
239
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7
|
|
240
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // c8 - cf
|
|
241
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7
|
|
242
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df
|
|
243
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // e0 - e7
|
|
244
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // e8 - ef
|
|
245
|
+
PCK4BITS(2,2,2,2,2,2,2,2), // f0 - f7
|
|
246
|
+
PCK4BITS(2,2,2,2,2,2,2,2) // f8 - ff
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
static const PRUint32 ISO2022KR_st [ 5] = {
|
|
251
|
+
PCK4BITS(eStart, 3,eError,eStart,eStart,eStart,eError,eError),//00-07
|
|
252
|
+
PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f
|
|
253
|
+
PCK4BITS(eItsMe,eItsMe,eError,eError,eError, 4,eError,eError),//10-17
|
|
254
|
+
PCK4BITS(eError,eError,eError,eError, 5,eError,eError,eError),//18-1f
|
|
255
|
+
PCK4BITS(eError,eError,eError,eItsMe,eStart,eStart,eStart,eStart) //20-27
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
static const PRUint32 ISO2022KRCharLenTable[] = {0, 0, 0, 0, 0, 0};
|
|
259
|
+
|
|
260
|
+
const SMModel ISO2022KRSMModel = {
|
|
261
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022KR_cls },
|
|
262
|
+
6,
|
|
263
|
+
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022KR_st },
|
|
264
|
+
ISO2022KRCharLenTable,
|
|
265
|
+
"ISO-2022-KR",
|
|
266
|
+
};
|
|
267
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
|
|
38
|
+
// for S-JIS encoding, obeserve characteristic:
|
|
39
|
+
// 1, kana character (or hankaku?) often have hight frequency of appereance
|
|
40
|
+
// 2, kana character often exist in group
|
|
41
|
+
// 3, certain combination of kana is never used in japanese language
|
|
42
|
+
|
|
43
|
+
#include "nsGB2312Prober.h"
|
|
44
|
+
|
|
45
|
+
void nsGB18030Prober::Reset(void)
|
|
46
|
+
{
|
|
47
|
+
mCodingSM->Reset();
|
|
48
|
+
mState = eDetecting;
|
|
49
|
+
mDistributionAnalyser.Reset(mIsPreferredLanguage);
|
|
50
|
+
//mContextAnalyser.Reset();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
nsProbingState nsGB18030Prober::HandleData(const char* aBuf, PRUint32 aLen)
|
|
54
|
+
{
|
|
55
|
+
PRUint32 codingState;
|
|
56
|
+
|
|
57
|
+
for (PRUint32 i = 0; i < aLen; i++)
|
|
58
|
+
{
|
|
59
|
+
codingState = mCodingSM->NextState(aBuf[i]);
|
|
60
|
+
if (codingState == eItsMe)
|
|
61
|
+
{
|
|
62
|
+
mState = eFoundIt;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
if (codingState == eStart)
|
|
66
|
+
{
|
|
67
|
+
PRUint32 charLen = mCodingSM->GetCurrentCharLen();
|
|
68
|
+
|
|
69
|
+
if (i == 0)
|
|
70
|
+
{
|
|
71
|
+
mLastChar[1] = aBuf[0];
|
|
72
|
+
mDistributionAnalyser.HandleOneChar(mLastChar, charLen);
|
|
73
|
+
}
|
|
74
|
+
else
|
|
75
|
+
mDistributionAnalyser.HandleOneChar(aBuf+i-1, charLen);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
mLastChar[0] = aBuf[aLen-1];
|
|
80
|
+
|
|
81
|
+
if (mState == eDetecting)
|
|
82
|
+
if (mDistributionAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD)
|
|
83
|
+
mState = eFoundIt;
|
|
84
|
+
// else
|
|
85
|
+
// mDistributionAnalyser.HandleData(aBuf, aLen);
|
|
86
|
+
|
|
87
|
+
return mState;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
float nsGB18030Prober::GetConfidence(void)
|
|
91
|
+
{
|
|
92
|
+
float distribCf = mDistributionAnalyser.GetConfidence();
|
|
93
|
+
|
|
94
|
+
return (float)distribCf;
|
|
95
|
+
}
|
|
96
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
|
|
38
|
+
#ifndef nsGB2312Prober_h__
|
|
39
|
+
#define nsGB2312Prober_h__
|
|
40
|
+
|
|
41
|
+
#include "nsCharSetProber.h"
|
|
42
|
+
#include "nsCodingStateMachine.h"
|
|
43
|
+
#include "CharDistribution.h"
|
|
44
|
+
|
|
45
|
+
// We use GB18030 to replace GB2312, because 18030 is a superset.
|
|
46
|
+
|
|
47
|
+
class nsGB18030Prober: public nsCharSetProber {
|
|
48
|
+
public:
|
|
49
|
+
nsGB18030Prober(PRBool aIsPreferredLanguage)
|
|
50
|
+
:mIsPreferredLanguage(aIsPreferredLanguage)
|
|
51
|
+
{mCodingSM = new nsCodingStateMachine(&GB18030SMModel);
|
|
52
|
+
Reset();}
|
|
53
|
+
virtual ~nsGB18030Prober(void){delete mCodingSM;}
|
|
54
|
+
nsProbingState HandleData(const char* aBuf, PRUint32 aLen);
|
|
55
|
+
const char* GetCharSetName() {return "GB18030";}
|
|
56
|
+
const char* GetLanguage() {return "zh";}
|
|
57
|
+
nsProbingState GetState(void) {return mState;}
|
|
58
|
+
void Reset(void);
|
|
59
|
+
float GetConfidence(void);
|
|
60
|
+
void SetOpion() {}
|
|
61
|
+
|
|
62
|
+
protected:
|
|
63
|
+
void GetDistribution(PRUint32 aCharLen, const char* aStr);
|
|
64
|
+
|
|
65
|
+
nsCodingStateMachine* mCodingSM;
|
|
66
|
+
nsProbingState mState;
|
|
67
|
+
|
|
68
|
+
//GB2312ContextAnalysis mContextAnalyser;
|
|
69
|
+
GB2312DistributionAnalysis mDistributionAnalyser;
|
|
70
|
+
char mLastChar[2];
|
|
71
|
+
PRBool mIsPreferredLanguage;
|
|
72
|
+
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
#endif /* nsGB2312Prober_h__ */
|
|
77
|
+
|