Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
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/. */
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 */
14 #ifndef nsUnicodeToGBK_h___
15 #define nsUnicodeToGBK_h___
17 #include "nsUCSupport.h"
18 #include "nsCOMPtr.h"
19 #include "nsIUnicodeEncoder.h"
20 #include "nsGBKConvUtil.h"
21 //----------------------------------------------------------------------
22 // Class nsUnicodeToGBK [declaration]
24 class nsUnicodeToGBK: public nsEncoderSupport
25 {
26 public:
28 /**
29 * Class constructor.
30 */
31 nsUnicodeToGBK(uint32_t aMaxLengthFactor = 2);
32 virtual ~nsUnicodeToGBK() {}
34 protected:
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);
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;
49 virtual void CreateExtensionEncoder();
50 virtual void Create4BytesEncoder();
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 };
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 };
73 #endif /* nsUnicodeToGBK_h___ */