Backed out changeset 6e5adc14dc82 (bug 964225)

This commit is contained in:
Ed Morley 2014-09-26 16:10:57 +01:00
Родитель 781a240255
Коммит 4a493a3d61
12 изменённых файлов: 292 добавлений и 25 удалений

Просмотреть файл

@ -27,8 +27,8 @@ locale.all.C=ISO-8859-1
# HP
locale.all.C.iso885915=ISO-8859-15
locale.all.c-french.iso88591=ISO-8859-1
locale.all.chinese=gb18030
locale.all.chinese-s=gb18030
locale.all.chinese=GB2312
locale.all.chinese-s=GB2312
locale.all.chinese-t.big5=Big5
locale.all.cs=ISO-8859-2
locale.all.cs_CZ=ISO-8859-2
@ -510,18 +510,18 @@ locale.all.th=windows-874
locale.all.th_TH.UTF-8=UTF-8
# RedHat 7 reported by Garaschenko Slava <slava@maze.ambernet.kiev.ua bug 70601
locale.all.uk_UA=KOI8-U
locale.all.zh=gb18030
locale.all.zh_CN=gb18030
locale.all.zh_CN.EUC=gb18030
locale.all.zh=GB2312
locale.all.zh_CN=GB2312
locale.all.zh_CN.EUC=GB2312
locale.all.zh.GBK=gbk
locale.all.zh_CN.UTF-8=UTF-8
locale.all.zh.UTF-8=UTF-8
locale.all.zh_TW.BIG5=Big5
# saw the following name from news://xcin.linux.org.tw/tlug.cle-devel
locale.all.zh_CN.gb18030=gb18030
locale.all.zh_CN.GB2312=GB2312
# AIX
locale.all.ZH_CN=UTF-8
locale.all.zh_CN.ugb=gb18030
locale.all.zh_CN.ugb=GB2312
locale.all.zh_CN.GBK=gbk
locale.all.zh_HK.big5=Big5
locale.all.zh_TW.big5=Big5

Просмотреть файл

@ -51,6 +51,7 @@ UNIFIED_SOURCES += [
'ucvcn/nsGBKConvUtil.cpp',
'ucvcn/nsGBKToUnicode.cpp',
'ucvcn/nsHZToUnicode.cpp',
'ucvcn/nsUnicodeToGB2312V2.cpp',
'ucvcn/nsUnicodeToGBK.cpp',
'ucvcn/nsUnicodeToHZ.cpp',
]

Просмотреть файл

@ -126,6 +126,8 @@
#include "nsUnicodeToHZ.h"
#include "nsGBKToUnicode.h"
#include "nsUnicodeToGBK.h"
#include "nsGB2312ToUnicodeV2.h"
#include "nsUnicodeToGB2312V2.h"
#include "gbku.h"
NS_CONVERTER_REGISTRY_START
@ -192,6 +194,7 @@ NS_UCONV_REG_UNREG("Big5-HKSCS", NS_BIG5HKSCSTOUNICODE_CID, NS_UNICODETOBIG5HKSC
NS_UCONV_REG_UNREG("EUC-KR", NS_EUCKRTOUNICODE_CID, NS_UNICODETOEUCKR_CID)
// ucvcn
NS_UCONV_REG_UNREG("GB2312", NS_GB2312TOUNICODE_CID, NS_UNICODETOGB2312_CID)
NS_UCONV_REG_UNREG("gbk", NS_GBKTOUNICODE_CID, NS_UNICODETOGBK_CID)
NS_UCONV_REG_UNREG("HZ-GB-2312", NS_HZTOUNICODE_CID, NS_UNICODETOHZ_CID)
NS_UCONV_REG_UNREG("gb18030", NS_GB18030TOUNICODE_CID, NS_UNICODETOGB18030_CID)
@ -221,6 +224,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToISO2022JP)
// ucvko
// ucvcn
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToGB2312V2)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToGBK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHZToUnicode)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToHZ)
@ -386,6 +390,8 @@ NS_DEFINE_NAMED_CID(NS_UNICODETOBIG5HKSCS_CID);
NS_DEFINE_NAMED_CID(NS_BIG5HKSCSTOUNICODE_CID);
NS_DEFINE_NAMED_CID(NS_EUCKRTOUNICODE_CID);
NS_DEFINE_NAMED_CID(NS_UNICODETOEUCKR_CID);
NS_DEFINE_NAMED_CID(NS_GB2312TOUNICODE_CID);
NS_DEFINE_NAMED_CID(NS_UNICODETOGB2312_CID);
NS_DEFINE_NAMED_CID(NS_GBKTOUNICODE_CID);
NS_DEFINE_NAMED_CID(NS_UNICODETOGBK_CID);
NS_DEFINE_NAMED_CID(NS_HZTOUNICODE_CID);
@ -492,6 +498,8 @@ static const mozilla::Module::CIDEntry kUConvCIDs[] = {
{ &kNS_BIG5HKSCSTOUNICODE_CID, false, nullptr, nsBIG5HKSCSToUnicodeConstructor },
{ &kNS_EUCKRTOUNICODE_CID, false, nullptr, nsCP949ToUnicodeConstructor },
{ &kNS_UNICODETOEUCKR_CID, false, nullptr, nsUnicodeToCP949Constructor },
{ &kNS_GB2312TOUNICODE_CID, false, nullptr, nsGB18030ToUnicodeConstructor },
{ &kNS_UNICODETOGB2312_CID, false, nullptr, nsUnicodeToGB2312V2Constructor },
{ &kNS_GBKTOUNICODE_CID, false, nullptr, nsGB18030ToUnicodeConstructor },
{ &kNS_UNICODETOGBK_CID, false, nullptr, nsUnicodeToGBKConstructor },
{ &kNS_HZTOUNICODE_CID, false, nullptr, nsHZToUnicodeConstructor },
@ -600,6 +608,8 @@ static const mozilla::Module::ContractIDEntry kUConvContracts[] = {
{ NS_UNICODEDECODER_CONTRACTID_BASE "Big5-HKSCS", &kNS_BIG5HKSCSTOUNICODE_CID },
{ NS_UNICODEDECODER_CONTRACTID_BASE "EUC-KR", &kNS_EUCKRTOUNICODE_CID },
{ NS_UNICODEENCODER_CONTRACTID_BASE "EUC-KR", &kNS_UNICODETOEUCKR_CID },
{ NS_UNICODEDECODER_CONTRACTID_BASE "GB2312", &kNS_GB2312TOUNICODE_CID },
{ NS_UNICODEENCODER_CONTRACTID_BASE "GB2312", &kNS_UNICODETOGB2312_CID },
{ NS_UNICODEDECODER_CONTRACTID_BASE "gbk", &kNS_GBKTOUNICODE_CID },
{ NS_UNICODEENCODER_CONTRACTID_BASE "gbk", &kNS_UNICODETOGBK_CID },
{ NS_UNICODEDECODER_CONTRACTID_BASE "HZ-GB-2312", &kNS_HZTOUNICODE_CID },

Просмотреть файл

@ -0,0 +1,47 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
/*========================================================
This is a Generated file. Please don't edit it.
The tool which used to generate this file is called umaptable.
You can find this tool under mozilla/intl/uconv/tools/umaptable.c.
If you have any problem of this file. Please contact
Netscape Client International Team or
ftang@netscape <Frank Tang>
Table in Debug form
Begin of Item 0000
Format 2
srcBegin = 0080
destBegin = 20AC
End of Item 0000
========================================================*/
/* Offset=0x0000 ItemOfList */
0x0001,
/*-------------------------------------------------------*/
/* Offset=0x0001 offsetToFormatArray */
0x0004,
/*-------------------------------------------------------*/
/* Offset=0x0002 offsetToMapCellArray */
0x0005,
/*-------------------------------------------------------*/
/* Offset=0x0003 offsetToMappingTable */
0x0008,
/*-------------------------------------------------------*/
/* Offset=0x0004 Start of Format Array */
/* Total of Format 0 : 0x0000 */
/* Total of Format 1 : 0x0000 */
/* Total of Format 2 : 0x0001 */
/* Total of Format 3 : 0x0000 */
0x0002,
/*-------------------------------------------------------*/
/* Offset=0x0005 Start of MapCell Array */
/* 0000 */ 0x0080, 0x0000, 0x20AC,
/*-------------------------------------------------------*/
/* Offset=0x0008 Start of MappingTable */
/* End of table Total Length = 0x0008 * 2 */

Просмотреть файл

@ -0,0 +1,32 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#ifndef nsGB2312ToUnicodeV2_h___
#define nsGB2312ToUnicodeV2_h___
#include "nsUCSupport.h"
#include "gbku.h"
#include "nsGBKToUnicode.h"
//----------------------------------------------------------------------
// Class nsGB2312ToUnicodeV2 [declaration]
/**
* A character set converter from GB2312 to Unicode.
*
* @created 06/Apr/1999
* @author Catalin Rotaru [CATA]
*/
class nsGB2312ToUnicodeV2 : public nsGB18030ToUnicode
{
public:
/**
* Class constructor.
*/
nsGB2312ToUnicodeV2(){}
};
#endif /* nsGB2312ToUnicodeV2_h___ */

Просмотреть файл

@ -13,6 +13,28 @@
#include "nsGBKToUnicode.h"
#include "gbku.h"
//------------------------------------------------------------
// nsGBKUnique2BytesToUnicode
//------------------------------------------------------------
class nsGBKUnique2BytesToUnicode : public nsTableDecoderSupport
{
public:
nsGBKUnique2BytesToUnicode();
virtual ~nsGBKUnique2BytesToUnicode()
{ }
protected:
};
static const uint16_t g_utGBKUnique2Bytes[] = {
#include "gbkuniq2b.ut"
};
nsGBKUnique2BytesToUnicode::nsGBKUnique2BytesToUnicode()
: nsTableDecoderSupport(u2BytesCharset, nullptr,
(uMappingTable*) &g_utGBKUnique2Bytes, 1)
{
}
//------------------------------------------------------------
// nsGB18030Unique2BytesToUnicode
//------------------------------------------------------------
@ -75,10 +97,10 @@ nsGB18030Unique4BytesToUnicode::nsGB18030Unique4BytesToUnicode()
#define LEGAL_GBK_4BYTE_FORTH_BYTE(c) \
(UINT8_IN_RANGE(0x30, (c), 0x39))
NS_IMETHODIMP nsGB18030ToUnicode::ConvertNoBuff(const char* aSrc,
int32_t * aSrcLength,
char16_t *aDest,
int32_t * aDestLength)
NS_IMETHODIMP nsGBKToUnicode::ConvertNoBuff(const char* aSrc,
int32_t * aSrcLength,
char16_t *aDest,
int32_t * aDestLength)
{
int32_t i=0;
int32_t iSrcLength = (*aSrcLength);
@ -207,6 +229,15 @@ NS_IMETHODIMP nsGB18030ToUnicode::ConvertNoBuff(const char* aSrc,
return rv;
}
void nsGBKToUnicode::CreateExtensionDecoder()
{
mExtensionDecoder = new nsGBKUnique2BytesToUnicode();
}
void nsGBKToUnicode::Create4BytesDecoder()
{
m4BytesDecoder = nullptr;
}
void nsGB18030ToUnicode::CreateExtensionDecoder()
{
mExtensionDecoder = new nsGB18030Unique2BytesToUnicode();
@ -248,7 +279,7 @@ bool nsGB18030ToUnicode::DecodeToSurrogate(const char* aSrc, char16_t* aOut)
return true;
}
bool nsGB18030ToUnicode::TryExtensionDecoder(const char* aSrc, char16_t* aOut)
bool nsGBKToUnicode::TryExtensionDecoder(const char* aSrc, char16_t* aOut)
{
if(!mExtensionDecoder)
CreateExtensionDecoder();
@ -269,8 +300,11 @@ bool nsGB18030ToUnicode::TryExtensionDecoder(const char* aSrc, char16_t* aOut)
}
return false;
}
bool nsGB18030ToUnicode::Try4BytesDecoder(const char* aSrc, char16_t* aOut)
bool nsGBKToUnicode::DecodeToSurrogate(const char* aSrc, char16_t* aOut)
{
return false;
}
bool nsGBKToUnicode::Try4BytesDecoder(const char* aSrc, char16_t* aOut)
{
if(!m4BytesDecoder)
Create4BytesDecoder();

Просмотреть файл

@ -2,8 +2,8 @@
/* 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/. */
#ifndef nsGBKToUnicode_h___
#define nsGBKToUnicode_h___
#ifndef nsGBK2312ToUnicode_h___
#define nsGBK2312ToUnicode_h___
#include "nsCOMPtr.h"
#include "nsIUnicodeDecoder.h"
@ -11,23 +11,23 @@
#include "nsGBKConvUtil.h"
//----------------------------------------------------------------------
// Class nsGB18030ToUnicode [declaration]
// Class nsGBKToUnicode [declaration]
/**
* A character set converter from GB18030 to Unicode.
* A character set converter from GBK to Unicode.
*
*
* @created 07/Sept/1999
* @author Yueheng Xu, Yueheng.Xu@intel.com
*/
class nsGB18030ToUnicode : public nsBufferDecoderSupport
class nsGBKToUnicode : public nsBufferDecoderSupport
{
public:
/**
* Class constructor.
*/
nsGB18030ToUnicode() : nsBufferDecoderSupport(1)
nsGBKToUnicode() : nsBufferDecoderSupport(1)
{
mExtensionDecoder = nullptr;
m4BytesDecoder = nullptr;
@ -44,13 +44,25 @@ protected:
nsCOMPtr<nsIUnicodeDecoder> mExtensionDecoder;
nsCOMPtr<nsIUnicodeDecoder> m4BytesDecoder;
void CreateExtensionDecoder();
void Create4BytesDecoder();
virtual void CreateExtensionDecoder();
virtual void Create4BytesDecoder();
bool TryExtensionDecoder(const char* aSrc, char16_t* aDest);
bool Try4BytesDecoder(const char* aSrc, char16_t* aDest);
bool DecodeToSurrogate(const char* aSrc, char16_t* aDest);
virtual bool DecodeToSurrogate(const char* aSrc, char16_t* aDest);
};
#endif /* nsGBKToUnicode_h___ */
class nsGB18030ToUnicode : public nsGBKToUnicode
{
public:
nsGB18030ToUnicode() {}
virtual ~nsGB18030ToUnicode() {}
protected:
virtual void CreateExtensionDecoder();
virtual void Create4BytesDecoder();
virtual bool DecodeToSurrogate(const char* aSrc, char16_t* aDest);
};
#endif /* nsGBK2312ToUnicode_h___ */

Просмотреть файл

@ -8,6 +8,10 @@
#include "nsISupports.h"
// Class ID for our GB2312ToUnicode charset converter// {379C2774-EC77-11d2-8AAC-00600811A836}
#define NS_GB2312TOUNICODE_CID \
{ 0x379c2774, 0xec77, 0x11d2, {0x8a, 0xac, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36}}
// Class ID for our HZToUnicode charset converter
// {BA61519A-1DFA-11d3-B3BF-00805F8A6670}
#define NS_HZTOUNICODE_CID \
@ -18,6 +22,11 @@
#define NS_GBKTOUNICODE_CID \
{ 0xba61519e, 0x1dfa, 0x11d3, {0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70}}
// Class ID for our UnicodeToGB2312 charset converter
// {379C2777-EC77-11d2-8AAC-00600811A836}
#define NS_UNICODETOGB2312_CID \
{ 0x379c2777, 0xec77, 0x11d2, {0x8a, 0xac, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36}}
// Class ID for our UnicodeToGBK charset converter
// {BA61519B-1DFA-11d3-B3BF-00805F8A6670}
#define NS_UNICODETOGBK_CID \

Просмотреть файл

@ -0,0 +1,65 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "nsUnicodeToGB2312V2.h"
#include "gbku.h"
//----------------------------------------------------------------------
// Class nsUnicodeToGB2312V2 [implementation]
nsUnicodeToGB2312V2::nsUnicodeToGB2312V2() :
nsEncoderSupport(2)
{
}
NS_IMETHODIMP nsUnicodeToGB2312V2::ConvertNoBuff(const char16_t * aSrc,
int32_t * aSrcLength,
char * aDest,
int32_t * aDestLength)
{
int32_t iSrcLength = 0;
int32_t iDestLength = 0;
nsresult res = NS_OK;
while (iSrcLength < *aSrcLength)
{
//if unicode's hi byte has something, it is not ASCII, must be a GB
if(IS_ASCII(*aSrc))
{
// this is an ASCII
*aDest = CAST_UNICHAR_TO_CHAR(*aSrc);
aDest++; // increment 1 byte
iDestLength +=1;
} else {
char byte1, byte2;
if(mUtil.UnicodeToGBKChar(*aSrc, false, &byte1, &byte2))
{
if(iDestLength+2 > *aDestLength)
{
res = NS_OK_UENC_MOREOUTPUT;
break;
}
aDest[0]=byte1;
aDest[1]=byte2;
aDest += 2; // increment 2 bytes
iDestLength +=2; // each GB char count as two in char* string
} else {
// cannot convert
res= NS_ERROR_UENC_NOMAPPING;
iSrcLength++; // include length of the unmapped character
break;
}
}
iSrcLength++ ; // each unicode char just count as one in char16_t* string
aSrc++;
if ( iDestLength >= (*aDestLength) && (iSrcLength < *aSrcLength ))
{
res = NS_OK_UENC_MOREOUTPUT;
break;
}
}
*aDestLength = iDestLength;
*aSrcLength = iSrcLength;
return res;
}

Просмотреть файл

@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#ifndef nsUnicodeToGB2312V2_h___
#define nsUnicodeToGB2312V2_h___
#include "nsUCSupport.h"
#include "nsGBKConvUtil.h"
//----------------------------------------------------------------------
// Class nsUnicodeToGB2312V2 [declaration]
/**
* A character set converter from Unicode to GB2312.
*
* @created 06/Apr/1999
* @author Catalin Rotaru [CATA]
*/
class nsUnicodeToGB2312V2 : public nsEncoderSupport
{
public:
/**
* Class constructor.
*/
nsUnicodeToGB2312V2();
protected:
NS_IMETHOD ConvertNoBuff(const char16_t * aSrc,
int32_t * aSrcLength,
char * aDest,
int32_t * aDestLength);
//--------------------------------------------------------------------
// Subclassing of nsEncoderSupport class [declaration]
NS_IMETHOD ConvertNoBuffNoErr(const char16_t * aSrc, int32_t * aSrcLength,
char * aDest, int32_t * aDestLength)
{
return NS_OK;
} // just make it not abstract;
protected:
nsGBKConvUtil mUtil;
};
#endif /* nsUnicodeToGB2312V2_h___ */

Просмотреть файл

@ -764,7 +764,7 @@ NS_IMETHODIMP nsISO2022JPToUnicodeV2::Convert(
if (!mGB2312Decoder) {
// creating a delegate converter (GB2312)
mGB2312Decoder =
EncodingUtils::DecoderForEncoding("gb18030");
EncodingUtils::DecoderForEncoding(NS_LITERAL_CSTRING("GB2312"));
}
if (!mGB2312Decoder) {// failed creating a delegate converter
goto error2;

Просмотреть файл

@ -64,8 +64,15 @@ ISO-8859-2.key = l
ISO-8859-2 = Central European (ISO)
# Chinese, Simplified
# LOCALIZATION NOTE (gbk.bis.key):
# gbk.bis.key never appears together with gbk.key and, hence, can be the same.
gbk.bis.key = S
gbk.bis = Chinese, Simplified
# The strings gbk.key, gbk and gb18030 are no longer used but are retained
# in order to enable backout after string freeze, just in case.
gbk.key = S
gbk = Chinese, Simplified (GBK)
gb18030 = Chinese, Simplified (GB18030)
# Chinese, Traditional
Big5.key = T