diff --git a/intl/uconv/ucvtw/Makefile.in b/intl/uconv/ucvtw/Makefile.in index 3e186e060dd..7c8094744c2 100644 --- a/intl/uconv/ucvtw/Makefile.in +++ b/intl/uconv/ucvtw/Makefile.in @@ -31,6 +31,7 @@ CSRCS = \ CPPSRCS = \ nsBIG5ToUnicode.cpp \ nsUnicodeToBIG5.cpp \ + nsUnicodeToBIG5NoAscii.cpp \ nsUCvTWSupport.cpp \ nsUCvTWDll.cpp \ $(NULL) diff --git a/intl/uconv/ucvtw/nsBIG5ToUnicode.cpp b/intl/uconv/ucvtw/nsBIG5ToUnicode.cpp index 348adcccf56..ed2ab57ecaa 100644 --- a/intl/uconv/ucvtw/nsBIG5ToUnicode.cpp +++ b/intl/uconv/ucvtw/nsBIG5ToUnicode.cpp @@ -18,16 +18,11 @@ */ #include "nsBIG5ToUnicode.h" +#include "nsUCvTWDll.h" //---------------------------------------------------------------------- // Global functions and data [declaration] -static PRUint16 g_BIG5MappingTable[] = { -#include "big5.ut" -}; -static PRUint16 g_ASCIIMappingTable[] = { - 0x0001, 0x0004, 0x0005, 0x0008, 0x0000, 0x0000, 0x007F, 0x0000 -}; static PRInt16 g_BIG5ShiftTable[] = { 0, u2BytesCharset, @@ -45,8 +40,8 @@ static PRInt16 *g_BIG5ShiftTableSet [] = { }; static PRUint16 *g_BIG5MappingTableSet [] ={ - g_ASCIIMappingTable, - g_BIG5MappingTable + g_ASCIIMapping, + g_utBIG5Mapping }; static uRange g_BIG5Ranges[] = { diff --git a/intl/uconv/ucvtw/nsUCvTWDll.cpp b/intl/uconv/ucvtw/nsUCvTWDll.cpp index 052b5cd11a1..b65f8efa794 100644 --- a/intl/uconv/ucvtw/nsUCvTWDll.cpp +++ b/intl/uconv/ucvtw/nsUCvTWDll.cpp @@ -48,6 +48,16 @@ static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); PRInt32 g_InstanceCount = 0; PRInt32 g_LockCount = 0; +PRUint16 g_ufBig5Mapping[] = { +#include "big5.uf" +}; +PRUint16 g_utBIG5Mapping[] = { +#include "big5.ut" +}; +PRUint16 g_ASCIIMapping[] = { + 0x0001, 0x0004, 0x0005, 0x0008, 0x0000, 0x0000, 0x007F, 0x0000 +}; + typedef nsresult (* fpCreateInstance) (nsISupports **); struct FactoryData diff --git a/intl/uconv/ucvtw/nsUCvTWDll.h b/intl/uconv/ucvtw/nsUCvTWDll.h index 14e29614830..89ea719f13a 100644 --- a/intl/uconv/ucvtw/nsUCvTWDll.h +++ b/intl/uconv/ucvtw/nsUCvTWDll.h @@ -24,5 +24,8 @@ extern "C" PRInt32 g_InstanceCount; extern "C" PRInt32 g_LockCount; +extern "C" PRUint16 g_ufBig5Mapping[]; +extern "C" PRUint16 g_utBIG5Mapping[]; +extern "C" PRUint16 g_ASCIIMapping[]; #endif /* nsUCvTWDll_h___ */ diff --git a/intl/uconv/ucvtw/nsUnicodeToBIG5.cpp b/intl/uconv/ucvtw/nsUnicodeToBIG5.cpp index c293cd9f574..131a61d3dbf 100644 --- a/intl/uconv/ucvtw/nsUnicodeToBIG5.cpp +++ b/intl/uconv/ucvtw/nsUnicodeToBIG5.cpp @@ -18,13 +18,11 @@ */ #include "nsUnicodeToBIG5.h" +#include "nsUCvTWDll.h" //---------------------------------------------------------------------- // Global functions and data [declaration] -static PRUint16 g_ufBig5Mapping[] = { -#include "big5.uf" -}; static PRUint16 gAsciiShiftTable[] = { 0, u1ByteCharset, @@ -36,12 +34,9 @@ static PRUint16 gBig5ShiftTable[] = { ShiftCell(0, 0, 0, 0, 0, 0, 0, 0), }; -static PRUint16 g_AsciiMapping[] = { - 0x0001, 0x0004, 0x0005, 0x0008, 0x0000, 0x0000, 0x007F, 0x0000 -}; static PRUint16 *g_Big5MappingTable[2] = { - g_AsciiMapping, + g_ASCIIMapping, g_ufBig5Mapping }; diff --git a/intl/uconv/ucvtw/nsUnicodeToBIG5NoAscii.cpp b/intl/uconv/ucvtw/nsUnicodeToBIG5NoAscii.cpp new file mode 100644 index 00000000000..80dd1476248 --- /dev/null +++ b/intl/uconv/ucvtw/nsUnicodeToBIG5NoAscii.cpp @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#include "nsUnicodeToBIG5NoAscii.h" +#include "nsUCvTWDll.h" + +//---------------------------------------------------------------------- +// Global functions and data [declaration] + +static PRUint16 gBig5ShiftTable[] = { + 0, u2BytesCharset, + ShiftCell(0, 0, 0, 0, 0, 0, 0, 0), +}; + + +//---------------------------------------------------------------------- +// Class nsUnicodeToBIG5NoAscii [implementation] + +nsUnicodeToBIG5NoAscii::nsUnicodeToBIG5NoAscii() +: nsTableEncoderSupport( (uShiftTable*) &gBig5ShiftTable, + (uMappingTable*) &g_ufBig5Mapping) +{ +} + +nsresult nsUnicodeToBIG5NoAscii::CreateInstance(nsISupports ** aResult) +{ + nsIUnicodeEncoder *p = new nsUnicodeToBIG5NoAscii(); + if(p) { + *aResult = p; + return NS_OK; + } + return NS_ERROR_OUT_OF_MEMORY; +} + +//---------------------------------------------------------------------- +// Subclassing of nsTableEncoderSupport class [implementation] + +NS_IMETHODIMP nsUnicodeToBIG5NoAscii::GetMaxLength(const PRUnichar * aSrc, + PRInt32 aSrcLength, + PRInt32 * aDestLength) +{ + *aDestLength = 2 * aSrcLength; + return NS_OK_UENC_EXACTLENGTH; +} diff --git a/intl/uconv/ucvtw/nsUnicodeToBIG5NoAscii.h b/intl/uconv/ucvtw/nsUnicodeToBIG5NoAscii.h new file mode 100644 index 00000000000..46cb9e3249a --- /dev/null +++ b/intl/uconv/ucvtw/nsUnicodeToBIG5NoAscii.h @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#ifndef nsUnicodeToBIG5NoAscii_h___ +#define nsUnicodeToBIG5NoAscii_h___ + +#include "nsUCvTWSupport.h" + +//---------------------------------------------------------------------- +// Class nsUnicodeToBIG5NoAscii [declaration] + +/** + * A character set converter from Unicode to BIG5NoAscii. + * + */ +class nsUnicodeToBIG5NoAscii : public nsTableEncoderSupport +{ +public: + + /** + * Class constructor. + */ + nsUnicodeToBIG5NoAscii(); + + /** + * Static class constructor. + */ + static nsresult CreateInstance(nsISupports **aResult); + +protected: + + //-------------------------------------------------------------------- + // Subclassing of nsEncoderSupport class [declaration] + + NS_IMETHOD GetMaxLength(const PRUnichar * aSrc, PRInt32 aSrcLength, + PRInt32 * aDestLength); +}; + +#endif /* nsUnicodeToBIG5NoAscii_h___ */