intl/uconv/ucvcn/nsUnicodeToGBK.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/uconv/ucvcn/nsUnicodeToGBK.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,74 @@
     1.4 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 + /**
    1.10 + * A character set converter from Unicode to GBK.
    1.11 + * 
    1.12 + *
    1.13 + * @created         08/Sept/1999
    1.14 + * @author  Yueheng Xu, Yueheng.Xu@intel.com
    1.15 + */
    1.16 +
    1.17 +#ifndef nsUnicodeToGBK_h___
    1.18 +#define nsUnicodeToGBK_h___
    1.19 +
    1.20 +#include "nsUCSupport.h"
    1.21 +#include "nsCOMPtr.h"
    1.22 +#include "nsIUnicodeEncoder.h"
    1.23 +#include "nsGBKConvUtil.h"
    1.24 +//----------------------------------------------------------------------
    1.25 +// Class nsUnicodeToGBK [declaration]
    1.26 +
    1.27 +class nsUnicodeToGBK: public nsEncoderSupport
    1.28 +{
    1.29 +public:
    1.30 +
    1.31 +  /**
    1.32 +   * Class constructor.
    1.33 +   */
    1.34 +  nsUnicodeToGBK(uint32_t aMaxLengthFactor = 2);
    1.35 +  virtual ~nsUnicodeToGBK() {}
    1.36 +
    1.37 +protected:
    1.38 +
    1.39 +  //--------------------------------------------------------------------
    1.40 +  // Subclassing of nsEncoderSupport class [declaration]
    1.41 +  NS_IMETHOD ConvertNoBuff(const char16_t * aSrc, 
    1.42 +                            int32_t * aSrcLength, 
    1.43 +                            char * aDest, 
    1.44 +                            int32_t * aDestLength);
    1.45 +
    1.46 +  NS_IMETHOD ConvertNoBuffNoErr(const char16_t * aSrc, int32_t * aSrcLength, 
    1.47 +                                char * aDest, int32_t * aDestLength)
    1.48 +  {
    1.49 +    return NS_OK;
    1.50 +  }  // just make it not abstract;
    1.51 +
    1.52 +  virtual void CreateExtensionEncoder();
    1.53 +  virtual void Create4BytesEncoder();
    1.54 +
    1.55 +  nsCOMPtr<nsIUnicodeEncoder> mExtensionEncoder;
    1.56 +  nsCOMPtr<nsIUnicodeEncoder> m4BytesEncoder;
    1.57 +protected:
    1.58 +  char16_t mSurrogateHigh;
    1.59 +  nsGBKConvUtil mUtil;
    1.60 +  bool TryExtensionEncoder(char16_t aChar, char* aDest, int32_t* aOutLen);
    1.61 +  bool Try4BytesEncoder(char16_t aChar, char* aDest, int32_t* aOutLen);
    1.62 +  virtual bool EncodeSurrogate(char16_t aSurrogateHigh, char16_t aSurrogateLow, char* aDest);
    1.63 +};
    1.64 +
    1.65 +class nsUnicodeToGB18030: public nsUnicodeToGBK
    1.66 +{
    1.67 +public:
    1.68 +  nsUnicodeToGB18030() : nsUnicodeToGBK(4) {}
    1.69 +  virtual ~nsUnicodeToGB18030() {}
    1.70 +protected:
    1.71 +  virtual void CreateExtensionEncoder();
    1.72 +  virtual void Create4BytesEncoder();
    1.73 +  virtual bool EncodeSurrogate(char16_t aSurrogateHigh, char16_t aSurrogateLow, char* aDest);
    1.74 +};
    1.75 +
    1.76 +#endif /* nsUnicodeToGBK_h___ */
    1.77 +

mercurial