michael@0: /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #ifndef nsGBK2312ToUnicode_h___ michael@0: #define nsGBK2312ToUnicode_h___ michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsIUnicodeDecoder.h" michael@0: #include "nsUCSupport.h" michael@0: #include "nsGBKConvUtil.h" michael@0: michael@0: //---------------------------------------------------------------------- michael@0: // Class nsGBKToUnicode [declaration] michael@0: michael@0: /** michael@0: * A character set converter from GBK to Unicode. michael@0: * michael@0: * michael@0: * @created 07/Sept/1999 michael@0: * @author Yueheng Xu, Yueheng.Xu@intel.com michael@0: */ michael@0: class nsGBKToUnicode : public nsBufferDecoderSupport michael@0: { michael@0: public: michael@0: michael@0: /** michael@0: * Class constructor. michael@0: */ michael@0: nsGBKToUnicode() : nsBufferDecoderSupport(1) michael@0: { michael@0: mExtensionDecoder = nullptr; michael@0: m4BytesDecoder = nullptr; michael@0: } michael@0: michael@0: protected: michael@0: michael@0: //-------------------------------------------------------------------- michael@0: // Subclassing of nsDecoderSupport class [declaration] michael@0: NS_IMETHOD ConvertNoBuff(const char* aSrc, int32_t * aSrcLength, char16_t *aDest, int32_t * aDestLength); michael@0: michael@0: protected: michael@0: nsGBKConvUtil mUtil; michael@0: nsCOMPtr mExtensionDecoder; michael@0: nsCOMPtr m4BytesDecoder; michael@0: michael@0: virtual void CreateExtensionDecoder(); michael@0: virtual void Create4BytesDecoder(); michael@0: bool TryExtensionDecoder(const char* aSrc, char16_t* aDest); michael@0: bool Try4BytesDecoder(const char* aSrc, char16_t* aDest); michael@0: virtual bool DecodeToSurrogate(const char* aSrc, char16_t* aDest); michael@0: michael@0: }; michael@0: michael@0: michael@0: class nsGB18030ToUnicode : public nsGBKToUnicode michael@0: { michael@0: public: michael@0: nsGB18030ToUnicode() {} michael@0: virtual ~nsGB18030ToUnicode() {} michael@0: protected: michael@0: virtual void CreateExtensionDecoder(); michael@0: virtual void Create4BytesDecoder(); michael@0: virtual bool DecodeToSurrogate(const char* aSrc, char16_t* aDest); michael@0: }; michael@0: michael@0: #endif /* nsGBK2312ToUnicode_h___ */ michael@0: