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: michael@0: /** michael@0: * A character set converter from Unicode to GBK. michael@0: * michael@0: * michael@0: * @created 08/Sept/1999 michael@0: * @author Yueheng Xu, Yueheng.Xu@intel.com michael@0: */ michael@0: michael@0: #ifndef nsUnicodeToGBK_h___ michael@0: #define nsUnicodeToGBK_h___ michael@0: michael@0: #include "nsUCSupport.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsIUnicodeEncoder.h" michael@0: #include "nsGBKConvUtil.h" michael@0: //---------------------------------------------------------------------- michael@0: // Class nsUnicodeToGBK [declaration] michael@0: michael@0: class nsUnicodeToGBK: public nsEncoderSupport michael@0: { michael@0: public: michael@0: michael@0: /** michael@0: * Class constructor. michael@0: */ michael@0: nsUnicodeToGBK(uint32_t aMaxLengthFactor = 2); michael@0: virtual ~nsUnicodeToGBK() {} michael@0: michael@0: protected: michael@0: michael@0: //-------------------------------------------------------------------- michael@0: // Subclassing of nsEncoderSupport class [declaration] michael@0: NS_IMETHOD ConvertNoBuff(const char16_t * aSrc, michael@0: int32_t * aSrcLength, michael@0: char * aDest, michael@0: int32_t * aDestLength); michael@0: michael@0: NS_IMETHOD ConvertNoBuffNoErr(const char16_t * aSrc, int32_t * aSrcLength, michael@0: char * aDest, int32_t * aDestLength) michael@0: { michael@0: return NS_OK; michael@0: } // just make it not abstract; michael@0: michael@0: virtual void CreateExtensionEncoder(); michael@0: virtual void Create4BytesEncoder(); michael@0: michael@0: nsCOMPtr mExtensionEncoder; michael@0: nsCOMPtr m4BytesEncoder; michael@0: protected: michael@0: char16_t mSurrogateHigh; michael@0: nsGBKConvUtil mUtil; michael@0: bool TryExtensionEncoder(char16_t aChar, char* aDest, int32_t* aOutLen); michael@0: bool Try4BytesEncoder(char16_t aChar, char* aDest, int32_t* aOutLen); michael@0: virtual bool EncodeSurrogate(char16_t aSurrogateHigh, char16_t aSurrogateLow, char* aDest); michael@0: }; michael@0: michael@0: class nsUnicodeToGB18030: public nsUnicodeToGBK michael@0: { michael@0: public: michael@0: nsUnicodeToGB18030() : nsUnicodeToGBK(4) {} michael@0: virtual ~nsUnicodeToGB18030() {} michael@0: protected: michael@0: virtual void CreateExtensionEncoder(); michael@0: virtual void Create4BytesEncoder(); michael@0: virtual bool EncodeSurrogate(char16_t aSurrogateHigh, char16_t aSurrogateLow, char* aDest); michael@0: }; michael@0: michael@0: #endif /* nsUnicodeToGBK_h___ */ michael@0: