File indexing completed on 2024-04-28 03:53:03

0001 /*  -*- C++ -*-
0002     SPDX-FileCopyrightText: 1998 Netscape Communications Corporation <developer@mozilla.org>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 
0007 #ifndef nsGB2312Prober_h__
0008 #define nsGB2312Prober_h__
0009 
0010 #include "CharDistribution.h"
0011 #include "nsCharSetProber.h"
0012 #include "nsCodingStateMachine.h"
0013 
0014 // We use gb18030 to replace gb2312, because 18030 is a superset.
0015 namespace kencodingprober
0016 {
0017 class KCODECS_NO_EXPORT nsGB18030Prober : public nsCharSetProber
0018 {
0019 public:
0020     nsGB18030Prober(void)
0021     {
0022         mCodingSM = new nsCodingStateMachine(&GB18030SMModel);
0023         Reset();
0024     }
0025     ~nsGB18030Prober(void) override
0026     {
0027         delete mCodingSM;
0028     }
0029     nsProbingState HandleData(const char *aBuf, unsigned int aLen) override;
0030     const char *GetCharSetName() override
0031     {
0032         return "gb18030";
0033     }
0034     nsProbingState GetState(void) override
0035     {
0036         return mState;
0037     }
0038     void Reset(void) override;
0039     float GetConfidence(void) override;
0040     void SetOpion() override
0041     {
0042     }
0043 
0044 protected:
0045     void GetDistribution(unsigned int aCharLen, const char *aStr);
0046 
0047     nsCodingStateMachine *mCodingSM;
0048     nsProbingState mState;
0049 
0050     // GB2312ContextAnalysis mContextAnalyser;
0051     GB2312DistributionAnalysis mDistributionAnalyser;
0052     char mLastChar[2];
0053 };
0054 }
0055 
0056 #endif /* nsGB2312Prober_h__ */