Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 #ifndef nsGBK2312ToUnicode_h___
6 #define nsGBK2312ToUnicode_h___
8 #include "nsCOMPtr.h"
9 #include "nsIUnicodeDecoder.h"
10 #include "nsUCSupport.h"
11 #include "nsGBKConvUtil.h"
13 //----------------------------------------------------------------------
14 // Class nsGBKToUnicode [declaration]
16 /**
17 * A character set converter from GBK to Unicode.
18 *
19 *
20 * @created 07/Sept/1999
21 * @author Yueheng Xu, Yueheng.Xu@intel.com
22 */
23 class nsGBKToUnicode : public nsBufferDecoderSupport
24 {
25 public:
27 /**
28 * Class constructor.
29 */
30 nsGBKToUnicode() : nsBufferDecoderSupport(1)
31 {
32 mExtensionDecoder = nullptr;
33 m4BytesDecoder = nullptr;
34 }
36 protected:
38 //--------------------------------------------------------------------
39 // Subclassing of nsDecoderSupport class [declaration]
40 NS_IMETHOD ConvertNoBuff(const char* aSrc, int32_t * aSrcLength, char16_t *aDest, int32_t * aDestLength);
42 protected:
43 nsGBKConvUtil mUtil;
44 nsCOMPtr<nsIUnicodeDecoder> mExtensionDecoder;
45 nsCOMPtr<nsIUnicodeDecoder> m4BytesDecoder;
47 virtual void CreateExtensionDecoder();
48 virtual void Create4BytesDecoder();
49 bool TryExtensionDecoder(const char* aSrc, char16_t* aDest);
50 bool Try4BytesDecoder(const char* aSrc, char16_t* aDest);
51 virtual bool DecodeToSurrogate(const char* aSrc, char16_t* aDest);
53 };
56 class nsGB18030ToUnicode : public nsGBKToUnicode
57 {
58 public:
59 nsGB18030ToUnicode() {}
60 virtual ~nsGB18030ToUnicode() {}
61 protected:
62 virtual void CreateExtensionDecoder();
63 virtual void Create4BytesDecoder();
64 virtual bool DecodeToSurrogate(const char* aSrc, char16_t* aDest);
65 };
67 #endif /* nsGBK2312ToUnicode_h___ */