intl/uconv/ucvcn/nsUnicodeToGBK.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:cea51c4690e1
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
6 /**
7 * A character set converter from Unicode to GBK.
8 *
9 *
10 * @created 08/Sept/1999
11 * @author Yueheng Xu, Yueheng.Xu@intel.com
12 */
13
14 #ifndef nsUnicodeToGBK_h___
15 #define nsUnicodeToGBK_h___
16
17 #include "nsUCSupport.h"
18 #include "nsCOMPtr.h"
19 #include "nsIUnicodeEncoder.h"
20 #include "nsGBKConvUtil.h"
21 //----------------------------------------------------------------------
22 // Class nsUnicodeToGBK [declaration]
23
24 class nsUnicodeToGBK: public nsEncoderSupport
25 {
26 public:
27
28 /**
29 * Class constructor.
30 */
31 nsUnicodeToGBK(uint32_t aMaxLengthFactor = 2);
32 virtual ~nsUnicodeToGBK() {}
33
34 protected:
35
36 //--------------------------------------------------------------------
37 // Subclassing of nsEncoderSupport class [declaration]
38 NS_IMETHOD ConvertNoBuff(const char16_t * aSrc,
39 int32_t * aSrcLength,
40 char * aDest,
41 int32_t * aDestLength);
42
43 NS_IMETHOD ConvertNoBuffNoErr(const char16_t * aSrc, int32_t * aSrcLength,
44 char * aDest, int32_t * aDestLength)
45 {
46 return NS_OK;
47 } // just make it not abstract;
48
49 virtual void CreateExtensionEncoder();
50 virtual void Create4BytesEncoder();
51
52 nsCOMPtr<nsIUnicodeEncoder> mExtensionEncoder;
53 nsCOMPtr<nsIUnicodeEncoder> m4BytesEncoder;
54 protected:
55 char16_t mSurrogateHigh;
56 nsGBKConvUtil mUtil;
57 bool TryExtensionEncoder(char16_t aChar, char* aDest, int32_t* aOutLen);
58 bool Try4BytesEncoder(char16_t aChar, char* aDest, int32_t* aOutLen);
59 virtual bool EncodeSurrogate(char16_t aSurrogateHigh, char16_t aSurrogateLow, char* aDest);
60 };
61
62 class nsUnicodeToGB18030: public nsUnicodeToGBK
63 {
64 public:
65 nsUnicodeToGB18030() : nsUnicodeToGBK(4) {}
66 virtual ~nsUnicodeToGB18030() {}
67 protected:
68 virtual void CreateExtensionEncoder();
69 virtual void Create4BytesEncoder();
70 virtual bool EncodeSurrogate(char16_t aSurrogateHigh, char16_t aSurrogateLow, char* aDest);
71 };
72
73 #endif /* nsUnicodeToGBK_h___ */
74

mercurial