KDECore
nsEUCJPProber.h
Go to the documentation of this file.00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 00002 /* -*- C++ -*- 00003 * Copyright (C) 1998 <developer@mozilla.org> 00004 * 00005 * 00006 * Permission is hereby granted, free of charge, to any person obtaining 00007 * a copy of this software and associated documentation files (the 00008 * "Software"), to deal in the Software without restriction, including 00009 * without limitation the rights to use, copy, modify, merge, publish, 00010 * distribute, sublicense, and/or sell copies of the Software, and to 00011 * permit persons to whom the Software is furnished to do so, subject to 00012 * the following conditions: 00013 * 00014 * The above copyright notice and this permission notice shall be included 00015 * in all copies or substantial portions of the Software. 00016 * 00017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00018 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00019 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00020 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00021 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00022 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00023 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00024 */ 00025 00026 // for S-JIS encoding, obeserve characteristic: 00027 // 1, kana character (or hankaku?) often have hight frequency of appereance 00028 // 2, kana character often exist in group 00029 // 3, certain combination of kana is never used in japanese language 00030 00031 #ifndef nsEUCJPProber_h__ 00032 #define nsEUCJPProber_h__ 00033 00034 #include "nsCharSetProber.h" 00035 #include "nsCodingStateMachine.h" 00036 #include "JpCntx.h" 00037 #include "CharDistribution.h" 00038 namespace kencodingprober { 00039 class KDE_NO_EXPORT nsEUCJPProber: public nsCharSetProber { 00040 public: 00041 nsEUCJPProber(void){mCodingSM = new nsCodingStateMachine(&EUCJPSMModel); 00042 Reset();}; 00043 virtual ~nsEUCJPProber(void){delete mCodingSM;}; 00044 nsProbingState HandleData(const char* aBuf, unsigned int aLen); 00045 const char* GetCharSetName() {return "EUC-JP";}; 00046 nsProbingState GetState(void) {return mState;}; 00047 void Reset(void); 00048 float GetConfidence(void); 00049 void SetOpion() {}; 00050 00051 protected: 00052 nsCodingStateMachine* mCodingSM; 00053 nsProbingState mState; 00054 00055 EUCJPContextAnalysis mContextAnalyser; 00056 EUCJPDistributionAnalysis mDistributionAnalyser; 00057 00058 char mLastChar[2]; 00059 }; 00060 } 00061 00062 #endif /* nsEUCJPProber_h__ */ 00063