2015-06-03 00:18:38 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 12:12:37 +01:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-09-13 19:27:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A character set converter from Unicode to GBK.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @created 08/Sept/1999
|
|
|
|
* @author Yueheng Xu, Yueheng.Xu@intel.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsUnicodeToGBK_h___
|
|
|
|
#define nsUnicodeToGBK_h___
|
|
|
|
|
2002-08-12 19:16:16 +00:00
|
|
|
#include "nsUCSupport.h"
|
2001-05-15 12:52:29 +00:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIUnicodeEncoder.h"
|
2013-09-27 12:45:04 -04:00
|
|
|
#include "nsGBKConvUtil.h"
|
1999-09-13 19:27:05 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Class nsUnicodeToGBK [declaration]
|
|
|
|
|
1999-09-22 03:35:31 +00:00
|
|
|
class nsUnicodeToGBK: public nsEncoderSupport
|
1999-09-13 19:27:05 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class constructor.
|
|
|
|
*/
|
2014-08-18 09:53:43 -04:00
|
|
|
explicit nsUnicodeToGBK(uint32_t aMaxLengthFactor = 2);
|
2007-04-23 07:21:53 -07:00
|
|
|
virtual ~nsUnicodeToGBK() {}
|
1999-09-13 19:27:05 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// Subclassing of nsEncoderSupport class [declaration]
|
2015-06-03 00:18:38 +03:00
|
|
|
NS_IMETHOD ConvertNoBuffNoErr(const char16_t * aSrc,
|
|
|
|
int32_t * aSrcLength,
|
|
|
|
char * aDest,
|
|
|
|
int32_t * aDestLength);
|
1999-09-22 03:35:31 +00:00
|
|
|
|
2001-05-15 12:52:29 +00:00
|
|
|
protected:
|
2014-01-04 10:02:17 -05:00
|
|
|
char16_t mSurrogateHigh;
|
2001-05-15 12:52:29 +00:00
|
|
|
nsGBKConvUtil mUtil;
|
2016-04-06 20:07:31 +09:00
|
|
|
virtual nsresult TryExtensionEncoder(char16_t aChar, char* aDest,
|
|
|
|
int32_t* aOutLen);
|
|
|
|
virtual nsresult Try4BytesEncoder(char16_t aChar, char* aDest,
|
|
|
|
int32_t* aOutLen);
|
2015-06-03 00:18:38 +03:00
|
|
|
virtual nsresult EncodeSurrogate(char16_t aSurrogateHigh,
|
|
|
|
char16_t aSurrogateLow, char* aDest,
|
|
|
|
int32_t aDestLength, int32_t aBufferLength);
|
2001-05-15 12:52:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsUnicodeToGB18030: public nsUnicodeToGBK
|
|
|
|
{
|
|
|
|
public:
|
2007-04-23 07:21:53 -07:00
|
|
|
nsUnicodeToGB18030() : nsUnicodeToGBK(4) {}
|
|
|
|
virtual ~nsUnicodeToGB18030() {}
|
2001-05-15 12:52:29 +00:00
|
|
|
protected:
|
2016-04-06 20:07:31 +09:00
|
|
|
virtual nsresult TryExtensionEncoder(char16_t aChar, char* aDest,
|
|
|
|
int32_t* aOutLen) override;
|
|
|
|
virtual nsresult Try4BytesEncoder(char16_t aChar, char* aDest,
|
|
|
|
int32_t* aOutLen) override;
|
2015-06-03 00:18:38 +03:00
|
|
|
virtual nsresult EncodeSurrogate(char16_t aSurrogateHigh,
|
|
|
|
char16_t aSurrogateLow, char* aDest,
|
2016-04-06 20:07:31 +09:00
|
|
|
int32_t aDestLength,
|
|
|
|
int32_t aBufferLength) override;
|
2001-05-15 12:52:29 +00:00
|
|
|
};
|
|
|
|
|
1999-09-13 19:27:05 +00:00
|
|
|
#endif /* nsUnicodeToGBK_h___ */
|
|
|
|
|