1/* -*- C++ -*-
2 SPDX-FileCopyrightText: 1998 Netscape Communications Corporation <developer@mozilla.org>
3
4 SPDX-License-Identifier: MIT
5*/
6
7#ifndef nsGB2312Prober_h__
8#define nsGB2312Prober_h__
9
10#include "CharDistribution.h"
11#include "nsCharSetProber.h"
12#include "nsCodingStateMachine.h"
13
14// We use gb18030 to replace gb2312, because 18030 is a superset.
15namespace kencodingprober
16{
17class KCODECS_NO_EXPORT nsGB18030Prober : public nsCharSetProber
18{
19public:
20 nsGB18030Prober(void)
21 {
22 mCodingSM = new nsCodingStateMachine(&GB18030SMModel);
23 Reset();
24 }
25 ~nsGB18030Prober(void) override
26 {
27 delete mCodingSM;
28 }
29 nsProbingState HandleData(const char *aBuf, unsigned int aLen) override;
30 const char *GetCharSetName() override
31 {
32 return "gb18030";
33 }
34 nsProbingState GetState(void) override
35 {
36 return mState;
37 }
38 void Reset(void) override;
39 float GetConfidence(void) override;
40
41protected:
42 void GetDistribution(unsigned int aCharLen, const char *aStr);
43
44 nsCodingStateMachine *mCodingSM;
45 nsProbingState mState;
46
47 // GB2312ContextAnalysis mContextAnalyser;
48 GB2312DistributionAnalysis mDistributionAnalyser;
49 char mLastChar[2];
50};
51}
52
53#endif /* nsGB2312Prober_h__ */
54

source code of kcodecs/src/probers/nsGB2312Prober.h