|
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/. */ |
|
5 |
|
6 #ifndef nsGB2312Prober_h__ |
|
7 #define nsGB2312Prober_h__ |
|
8 |
|
9 #include "nsCharSetProber.h" |
|
10 #include "nsCodingStateMachine.h" |
|
11 #include "CharDistribution.h" |
|
12 |
|
13 // We use gb18030 to replace gb2312, because 18030 is a superset. |
|
14 |
|
15 class nsGB18030Prober: public nsCharSetProber { |
|
16 public: |
|
17 nsGB18030Prober(bool aIsPreferredLanguage) |
|
18 :mIsPreferredLanguage(aIsPreferredLanguage) |
|
19 {mCodingSM = new nsCodingStateMachine(&GB18030SMModel); |
|
20 Reset();} |
|
21 virtual ~nsGB18030Prober(void){delete mCodingSM;} |
|
22 nsProbingState HandleData(const char* aBuf, uint32_t aLen); |
|
23 const char* GetCharSetName() {return "gb18030";} |
|
24 nsProbingState GetState(void) {return mState;} |
|
25 void Reset(void); |
|
26 float GetConfidence(void); |
|
27 |
|
28 protected: |
|
29 void GetDistribution(uint32_t aCharLen, const char* aStr); |
|
30 |
|
31 nsCodingStateMachine* mCodingSM; |
|
32 nsProbingState mState; |
|
33 |
|
34 //GB2312ContextAnalysis mContextAnalyser; |
|
35 GB2312DistributionAnalysis mDistributionAnalyser; |
|
36 char mLastChar[2]; |
|
37 bool mIsPreferredLanguage; |
|
38 |
|
39 }; |
|
40 |
|
41 |
|
42 #endif /* nsGB2312Prober_h__ */ |
|
43 |