1 /**
2  * @file    nsSJISProber.h
3  * @brief   nsSJISProber
4  * @license GPL 2.0/LGPL 2.1
5  */
6 
7 // for S-JIS encoding, obeserve characteristic:
8 // 1, kana character (or hankaku?) often have hight frequency of appereance
9 // 2, kana character often exist in group
10 // 3, certain combination of kana is never used in japanese language
11 
12 #ifndef nsSJISProber_h__
13 #define nsSJISProber_h__
14 
15 #include "nsCharSetProber.h"
16 #include "nsCodingStateMachine.h"
17 #include "JpCntx.h"
18 #include "CharDistribution.h"
19 
20 
21 class nsSJISProber: public nsCharSetProber {
22 public:
nsSJISProber(bool aIsPreferredLanguage)23   nsSJISProber(bool aIsPreferredLanguage)
24     :mIsPreferredLanguage(aIsPreferredLanguage)
25   {mCodingSM = new nsCodingStateMachine(&SJISSMModel);
26     Reset();}
~nsSJISProber(void)27   virtual ~nsSJISProber(void){delete mCodingSM;}
28   nsProbingState HandleData(const char* aBuf, PRUint32 aLen);
GetCharSetName()29   const char* GetCharSetName() {return "Shift_JIS";}
GetState(void)30   nsProbingState GetState(void) {return mState;}
31   void      Reset(void);
32   float     GetConfidence(void);
33 
34 protected:
35   nsCodingStateMachine* mCodingSM;
36   nsProbingState mState;
37 
38   SJISContextAnalysis mContextAnalyser;
39   SJISDistributionAnalysis mDistributionAnalyser;
40 
41   char mLastChar[2];
42   bool mIsPreferredLanguage;
43 
44 };
45 
46 
47 #endif /* nsSJISProber_h__ */
48 
49