Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 // for S-JIS encoding, obeserve characteristic:
7 // 1, kana character (or hankaku?) often have hight frequency of appereance
8 // 2, kana character often exist in group
9 // 3, certain combination of kana is never used in japanese language
11 #ifndef nsSJISProber_h__
12 #define nsSJISProber_h__
14 #include "nsCharSetProber.h"
15 #include "nsCodingStateMachine.h"
16 #include "JpCntx.h"
17 #include "CharDistribution.h"
20 class nsSJISProber: public nsCharSetProber {
21 public:
22 nsSJISProber(bool aIsPreferredLanguage)
23 :mIsPreferredLanguage(aIsPreferredLanguage)
24 {mCodingSM = new nsCodingStateMachine(&SJISSMModel);
25 Reset();}
26 virtual ~nsSJISProber(void){delete mCodingSM;}
27 nsProbingState HandleData(const char* aBuf, uint32_t aLen);
28 const char* GetCharSetName() {return "Shift_JIS";}
29 nsProbingState GetState(void) {return mState;}
30 void Reset(void);
31 float GetConfidence(void);
33 protected:
34 nsCodingStateMachine* mCodingSM;
35 nsProbingState mState;
37 SJISContextAnalysis mContextAnalyser;
38 SJISDistributionAnalysis mDistributionAnalyser;
40 char mLastChar[2];
41 bool mIsPreferredLanguage;
43 };
46 #endif /* nsSJISProber_h__ */