| |
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___ |
| |
7 |
| |
8 #include "nsCOMPtr.h" |
| |
9 #include "nsIUnicodeDecoder.h" |
| |
10 #include "nsUCSupport.h" |
| |
11 #include "nsGBKConvUtil.h" |
| |
12 |
| |
13 //---------------------------------------------------------------------- |
| |
14 // Class nsGBKToUnicode [declaration] |
| |
15 |
| |
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: |
| |
26 |
| |
27 /** |
| |
28 * Class constructor. |
| |
29 */ |
| |
30 nsGBKToUnicode() : nsBufferDecoderSupport(1) |
| |
31 { |
| |
32 mExtensionDecoder = nullptr; |
| |
33 m4BytesDecoder = nullptr; |
| |
34 } |
| |
35 |
| |
36 protected: |
| |
37 |
| |
38 //-------------------------------------------------------------------- |
| |
39 // Subclassing of nsDecoderSupport class [declaration] |
| |
40 NS_IMETHOD ConvertNoBuff(const char* aSrc, int32_t * aSrcLength, char16_t *aDest, int32_t * aDestLength); |
| |
41 |
| |
42 protected: |
| |
43 nsGBKConvUtil mUtil; |
| |
44 nsCOMPtr<nsIUnicodeDecoder> mExtensionDecoder; |
| |
45 nsCOMPtr<nsIUnicodeDecoder> m4BytesDecoder; |
| |
46 |
| |
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); |
| |
52 |
| |
53 }; |
| |
54 |
| |
55 |
| |
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 }; |
| |
66 |
| |
67 #endif /* nsGBK2312ToUnicode_h___ */ |
| |
68 |