This commit is contained in:
cata%netscape.com 1999-04-06 21:11:54 +00:00
Родитель dfbd147803
Коммит 6a4677a035
12 изменённых файлов: 12687 добавлений и 0 удалений

5905
intl/uconv/ucvcn/big5.uf Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

5175
intl/uconv/ucvcn/big5.ut Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,72 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..
DEFINES=-D_IMPL_NS_INTL -DWIN32_LEAN_AND_MEAN
MODULE=uconv
REQUIRES=xpcom uconv
MAKE_OBJ_TYPE = DLL
DLLNAME = ucvcn
DLL=.\$(OBJDIR)\$(DLLNAME).dll
CPPSRCS = \
nsBIG5ToUnicode.cpp \
nsUnicodeToBIG5.cpp \
nsUCvCnSupport.cpp \
nsUCvCnDll.cpp \
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\nsBIG5ToUnicode.obj \
.\$(OBJDIR)\nsUnicodeToBIG5.obj \
.\$(OBJDIR)\nsUCvCnSupport.obj \
.\$(OBJDIR)\nsUCvCnDll.obj \
$(NULL)
EXPORTS=nsUCvCnCID.h \
$(NULL)
LINCS= \
-I$(PUBLIC)\raptor \
-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\uconv \
$(NULL)
LLIBS= \
$(DIST)\lib\xpcom32.lib \
$(DIST)\lib\raptorbase.lib \
$(LIBNSPR)
MISCDEP = $(LLIBS)
LCFLAGS = \
$(LCFLAGS) \
$(DEFINES) \
$(NULL)
include <$(DEPTH)\config\rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
clobber::
rm -f $(DIST)\bin\components\$(DLLNAME).dll
rm -f $(DIST)\bin\$(DLLNAME).lib

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

@ -0,0 +1,59 @@
/* -*- 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 "nsBIG5ToUnicode.h"
//----------------------------------------------------------------------
// Global functions and data [declaration]
static PRUint16 g_BIG5MappingTable[] = {
#include "big5.ut"
};
static PRInt16 g_BIG5ShiftTable[] = {
1, u1ByteCharset ,
ShiftCell(0,0,0,0,0,0,0,0)
};
//----------------------------------------------------------------------
// Class nsBIG5ToUnicode [implementation]
nsBIG5ToUnicode::nsBIG5ToUnicode()
: nsTableDecoderSupport((uShiftTable*) &g_BIG5ShiftTable,
(uMappingTable*) &g_BIG5MappingTable)
{
}
nsresult nsBIG5ToUnicode::CreateInstance(nsISupports ** aResult)
{
*aResult = new nsBIG5ToUnicode();
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
}
//----------------------------------------------------------------------
// Subclassing of nsTableDecoderSupport class [implementation]
NS_IMETHODIMP nsBIG5ToUnicode::GetMaxLength(const char * aSrc,
PRInt32 aSrcLength,
PRInt32 * aDestLength)
{
// we are a single byte to Unicode converter, so...
*aDestLength = aSrcLength;
return NS_OK_UDEC_EXACTLENGTH;
}

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

@ -0,0 +1,57 @@
/* -*- 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 nsBIG5ToUnicode_h___
#define nsBIG5ToUnicode_h___
#include "nsUCvCnSupport.h"
//----------------------------------------------------------------------
// Class nsBIG5ToUnicode [declaration]
/**
* A character set converter from BIG5 to Unicode.
*
* @created 06/Apr/1999
* @author Catalin Rotaru [CATA]
*/
class nsBIG5ToUnicode : public nsTableDecoderSupport
{
public:
/**
* Class constructor.
*/
nsBIG5ToUnicode();
/**
* Static class constructor.
*/
static nsresult CreateInstance(nsISupports **aResult);
protected:
//--------------------------------------------------------------------
// Subclassing of nsDecoderSupport class [declaration]
NS_IMETHOD GetMaxLength(const char * aSrc, PRInt32 aSrcLength,
PRInt32 * aDestLength);
};
#endif /* nsBIG5ToUnicode_h___ */

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

@ -0,0 +1,35 @@
/* -*- 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 nsUCvCnCID_h___
#define nsUCvCnCID_h___
#include "nsISupports.h"
// Class ID for our BIG5ToUnicode charset converter
// {EFC323E1-EC62-11d2-8AAC-00600811A836}
NS_DECLARE_ID(kBIG5ToUnicodeCID,
0xefc323e1, 0xec62, 0x11d2, 0x8a, 0xac, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36);
// Class ID for our UnicodeToBIG5 charset converter
// {EFC323E2-EC62-11d2-8AAC-00600811A836}
NS_DECLARE_ID(kUnicodeToBIG5CID,
0xefc323e2, 0xec62, 0x11d2, 0x8a, 0xac, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36);
#endif /* nsUCvCnCID_h___ */

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

@ -0,0 +1,295 @@
/* -*- 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.
*/
#define NS_IMPL_IDS
#include "pratom.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIFactory.h"
#include "nsCOMPtr.h"
#include "nsICharsetConverterInfo.h"
#include "nsUCvCnCID.h"
#include "nsUCvCnDll.h"
#include "nsBIG5ToUnicode.h"
#include "nsUnicodeToBIG5.h"
// just for NS_IMPL_IDS; this is a good, central place to implement GUIDs
#include "nsIUnicodeDecoder.h"
#include "nsIUnicodeDecodeUtil.h"
#include "nsIUnicodeDecodeHelper.h"
#include "nsIUnicodeEncoder.h"
#include "nsIUnicodeEncodeHelper.h"
#include "nsICharsetConverterManager.h"
//----------------------------------------------------------------------
// Global functions and data [declaration]
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
PRInt32 g_InstanceCount = 0;
PRInt32 g_LockCount = 0;
typedef nsresult (* fpCreateInstance) (nsISupports **);
struct FactoryData
{
const nsCID * mCID;
fpCreateInstance CreateInstance;
char * mCharsetSrc;
char * mCharsetDest;
};
FactoryData g_FactoryData[] =
{
{
&kBIG5ToUnicodeCID,
nsBIG5ToUnicode::CreateInstance,
"BIG5",
"Unicode"
},
{
&kUnicodeToBIG5CID,
nsUnicodeToBIG5::CreateInstance,
"Unicode",
"BIG5"
}
};
#define ARRAY_SIZE(_array) \
(sizeof(_array) / sizeof(_array[0]))
//----------------------------------------------------------------------
// Class nsConverterFactory [declaration]
/**
* General factory class for converter objects.
*
* @created 24/Feb/1998
* @author Catalin Rotaru [CATA]
*/
class nsConverterFactory : public nsIFactory,
public nsICharsetConverterInfo
{
NS_DECL_ISUPPORTS
private:
FactoryData * mData;
public:
/**
* Class constructor.
*/
nsConverterFactory(FactoryData * aData);
/**
* Class destructor.
*/
virtual ~nsConverterFactory();
//--------------------------------------------------------------------
// Interface nsIFactory [declaration]
NS_IMETHOD CreateInstance(nsISupports *aDelegate, const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
//--------------------------------------------------------------------
// Interface nsICharsetConverterInfo [declaration]
NS_IMETHOD GetCharsetSrc(char ** aCharset);
NS_IMETHOD GetCharsetDest(char ** aCharset);
};
//----------------------------------------------------------------------
// Global functions and data [implementation]
extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* aServMgr)
{
return PRBool(g_InstanceCount == 0 && g_LockCount == 0);
}
extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (aFactory == NULL) return NS_ERROR_NULL_POINTER;
nsresult res;
nsConverterFactory * fac;
FactoryData * data;
for (PRUint32 i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
data = &(g_FactoryData[i]);
if (aClass.Equals(*(data->mCID))) {
fac = new nsConverterFactory(data);
res = fac->QueryInterface(kIFactoryIID, (void **) aFactory);
if (NS_FAILED(res)) {
*aFactory = NULL;
delete fac;
}
return res;
}
}
return NS_NOINTERFACE;
}
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char * path)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
nsIComponentManager* compMgr;
rv = servMgr->GetService(kComponentManagerCID,
nsIComponentManager::GetIID(),
(nsISupports**)&compMgr);
if (NS_FAILED(rv)) return rv;
for (PRUint32 i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
rv = compMgr->RegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL,
path, PR_TRUE, PR_TRUE);
if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) goto done;
}
done:
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
}
extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char * path)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
nsIComponentManager* compMgr;
rv = servMgr->GetService(kComponentManagerCID,
nsIComponentManager::GetIID(),
(nsISupports**)&compMgr);
if (NS_FAILED(rv)) return rv;
for (PRUint32 i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
rv = compMgr->UnregisterFactory(*(g_FactoryData[i].mCID), path);
if(NS_FAILED(rv)) goto done;
}
done:
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
}
//----------------------------------------------------------------------
// Class nsConverterFactory [implementation]
nsConverterFactory::nsConverterFactory(FactoryData * aData)
{
mData = aData;
NS_INIT_REFCNT();
PR_AtomicIncrement(&g_InstanceCount);
}
nsConverterFactory::~nsConverterFactory()
{
PR_AtomicDecrement(&g_InstanceCount);
}
//----------------------------------------------------------------------
// Interface nsISupports [implementation]
NS_IMPL_ADDREF(nsConverterFactory);
NS_IMPL_RELEASE(nsConverterFactory);
nsresult nsConverterFactory::QueryInterface(REFNSIID aIID,
void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtr = NULL;
if (aIID.Equals(kICharsetConverterInfoIID)) {
*aInstancePtr = (void*) ((nsICharsetConverterInfo*)this);
} else if (aIID.Equals(kIFactoryIID)) {
*aInstancePtr = (void*) ((nsIFactory*)this);
} else if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) ((nsISupports*)(nsIFactory*)this);
} else {
return NS_NOINTERFACE;
}
NS_ADDREF_THIS();
return NS_OK;
}
//----------------------------------------------------------------------
// Interface nsIFactory [implementation]
NS_IMETHODIMP nsConverterFactory::CreateInstance(nsISupports *aDelegate,
const nsIID &aIID,
void **aResult)
{
if (aResult == NULL) return NS_ERROR_NULL_POINTER;
if (aDelegate != NULL) return NS_ERROR_NO_AGGREGATION;
nsISupports * t;
mData->CreateInstance(&t);
if (t == NULL) return NS_ERROR_OUT_OF_MEMORY;
nsresult res = t->QueryInterface(aIID, aResult);
if (NS_FAILED(res)) delete t;
return res;
}
NS_IMETHODIMP nsConverterFactory::LockFactory(PRBool aLock)
{
if (aLock) PR_AtomicIncrement(&g_LockCount);
else PR_AtomicDecrement(&g_LockCount);
return NS_OK;
}
//----------------------------------------------------------------------
// Interface nsICharsetConverterInfo [implementation]
NS_IMETHODIMP nsConverterFactory::GetCharsetSrc(char ** aCharset)
{
(*aCharset) = mData->mCharsetSrc;
return NS_OK;
}
NS_IMETHODIMP nsConverterFactory::GetCharsetDest(char ** aCharset)
{
(*aCharset) = mData->mCharsetDest;
return NS_OK;
}

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

@ -0,0 +1,28 @@
/* -*- 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 nsUCvCnDll_h___
#define nsUCvCnDll_h___
#include "prtypes.h"
extern PRInt32 g_InstanceCount;
extern PRInt32 g_LockCount;
#endif /* nsUCvCnDll_h___ */

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

@ -0,0 +1,613 @@
/* -*- 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 "pratom.h"
#include "nsIComponentManager.h"
#include "nsUCvCnSupport.h"
#include "nsUCvCnDll.h"
#define DEFAULT_BUFFER_CAPACITY 16
//----------------------------------------------------------------------
// Class nsEncoderSupport [implementation]
nsEncoderSupport::nsEncoderSupport()
{
mBufferCapacity = DEFAULT_BUFFER_CAPACITY;
mBuffer = new char[mBufferCapacity];
mErrBehavior = kOnError_Signal;
mErrChar = 0;
mErrEncoder = NULL;
Reset();
NS_INIT_REFCNT();
PR_AtomicIncrement(&g_InstanceCount);
}
nsEncoderSupport::~nsEncoderSupport()
{
delete [] mBuffer;
NS_IF_RELEASE(mErrEncoder);
PR_AtomicDecrement(&g_InstanceCount);
}
NS_IMETHODIMP nsEncoderSupport::ConvertNoBuff(const PRUnichar * aSrc,
PRInt32 * aSrcLength,
char * aDest,
PRInt32 * aDestLength)
{
// we do all operations using pointers internally
const PRUnichar * src = aSrc;
const PRUnichar * srcEnd = aSrc + *aSrcLength;
char * dest = aDest;
char * destEnd = aDest + *aDestLength;
PRInt32 bcr, bcw; // byte counts for read & write;
nsresult res;
for (;;) {
bcr = srcEnd - src;
bcw = destEnd - dest;
res = ConvertNoBuffNoErr(src, &bcr, dest, &bcw);
src += bcr;
dest += bcw;
if (res == NS_ERROR_UENC_NOMAPPING) {
if (mErrBehavior == kOnError_Replace) {
const PRUnichar buff[] = {mErrChar};
bcr = 1;
bcw = destEnd - dest;
src--; // back the input: maybe the guy won't consume consume anything.
res = ConvertNoBuffNoErr(buff, &bcr, dest, &bcw);
src += bcr;
dest += bcw;
if (res != NS_OK) break;
} else if (mErrBehavior == kOnError_CallBack) {
bcw = destEnd - dest;
src--;
res = mErrEncoder->Convert(*src, dest, &bcw);
dest += bcw;
// if enought output space then the last char was used
if (res != NS_OK_UENC_MOREOUTPUT) src++;
if (res != NS_OK) break;
} else break;
}
else break;
}
*aSrcLength -= srcEnd - src;
*aDestLength -= destEnd - dest;
return res;
}
NS_IMETHODIMP nsEncoderSupport::FinishNoBuff(char * aDest,
PRInt32 * aDestLength)
{
*aDestLength = 0;
return NS_OK;
}
nsresult nsEncoderSupport::FlushBuffer(char ** aDest, const char * aDestEnd)
{
PRInt32 bcr, bcw; // byte counts for read & write;
nsresult res = NS_OK;
char * dest = *aDest;
if (mBufferStart < mBufferEnd) {
bcr = mBufferEnd - mBufferStart;
bcw = aDestEnd - dest;
if (bcw < bcr) bcr = bcw;
memcpy(dest, mBufferStart, bcr);
dest += bcr;
mBufferStart += bcr;
if (mBufferStart < mBufferEnd) res = NS_OK_UENC_MOREOUTPUT;
}
*aDest = dest;
return res;
}
//----------------------------------------------------------------------
// Interface nsISupports [implementation]
NS_IMPL_ADDREF(nsEncoderSupport);
NS_IMPL_RELEASE(nsEncoderSupport);
nsresult nsEncoderSupport::QueryInterface(REFNSIID aIID,
void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtr = NULL;
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kIUnicodeEncoderIID)) {
*aInstancePtr = (void*) ((nsIUnicodeEncoder*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) ((nsISupports*)this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
//----------------------------------------------------------------------
// Interface nsIUnicodeEncoder [implementation]
NS_IMETHODIMP nsEncoderSupport::Convert(const PRUnichar * aSrc,
PRInt32 * aSrcLength,
char * aDest,
PRInt32 * aDestLength)
{
// we do all operations using pointers internally
const PRUnichar * src = aSrc;
const PRUnichar * srcEnd = aSrc + *aSrcLength;
char * dest = aDest;
char * destEnd = aDest + *aDestLength;
PRInt32 bcr, bcw; // byte counts for read & write;
nsresult res;
res = FlushBuffer(&dest, destEnd);
if (res == NS_OK_UENC_MOREOUTPUT) goto final;
bcr = srcEnd - src;
bcw = destEnd - dest;
res = ConvertNoBuff(src, &bcr, dest, &bcw);
src += bcr;
dest += bcw;
if ((res == NS_OK_UENC_MOREOUTPUT) && (dest < destEnd)) {
// convert exactly one character into the internal buffer
// at this point, there should be at least a char in the input
for (;;) {
bcr = 1;
bcw = mBufferCapacity;
res = ConvertNoBuff(src, &bcr, mBuffer, &bcw);
if (res == NS_OK_UENC_MOREOUTPUT) {
delete [] mBuffer;
mBufferCapacity *= 2;
mBuffer = new char [mBufferCapacity];
} else {
src += bcr;
mBufferStart = mBufferEnd = mBuffer;
mBufferEnd += bcw;
break;
}
}
res = FlushBuffer(&dest, destEnd);
}
final:
*aSrcLength -= srcEnd - src;
*aDestLength -= destEnd - dest;
return res;
}
NS_IMETHODIMP nsEncoderSupport::Finish(char * aDest, PRInt32 * aDestLength)
{
// we do all operations using pointers internally
char * dest = aDest;
char * destEnd = aDest + *aDestLength;
PRInt32 bcw; // byte count for write;
nsresult res;
res = FlushBuffer(&dest, destEnd);
if (res == NS_OK_UENC_MOREOUTPUT) goto final;
// do the finish into the internal buffer.
for (;;) {
bcw = mBufferCapacity;
res = FinishNoBuff(mBuffer, &bcw);
if (res == NS_OK_UENC_MOREOUTPUT) {
delete [] mBuffer;
mBufferCapacity *= 2;
mBuffer = new char [mBufferCapacity];
} else {
mBufferStart = mBufferEnd = mBuffer;
mBufferEnd += bcw;
break;
}
}
res = FlushBuffer(&dest, destEnd);
final:
*aDestLength -= destEnd - dest;
return res;
}
NS_IMETHODIMP nsEncoderSupport::Reset()
{
mBufferStart = mBufferEnd = mBuffer;
return NS_OK;
}
NS_IMETHODIMP nsEncoderSupport::SetOutputErrorBehavior(
PRInt32 aBehavior,
nsIUnicharEncoder * aEncoder,
PRUnichar aChar)
{
if ((aBehavior == kOnError_CallBack) && (aEncoder == NULL))
return NS_ERROR_NULL_POINTER;
NS_IF_RELEASE(aEncoder);
mErrEncoder = aEncoder;
NS_IF_ADDREF(aEncoder);
mErrBehavior = aBehavior;
mErrChar = aChar;
return NS_OK;
}
//----------------------------------------------------------------------
// Class nsTableEncoderSupport [implementation]
nsTableEncoderSupport::nsTableEncoderSupport(uShiftTable * aShiftTable,
uMappingTable * aMappingTable)
: nsEncoderSupport()
{
mHelper = NULL;
mShiftTable = aShiftTable;
mMappingTable = aMappingTable;
}
nsTableEncoderSupport::~nsTableEncoderSupport()
{
NS_IF_RELEASE(mHelper);
}
//----------------------------------------------------------------------
// Subclassing of nsEncoderSupport class [implementation]
NS_IMETHODIMP nsTableEncoderSupport::ConvertNoBuffNoErr(
const PRUnichar * aSrc,
PRInt32 * aSrcLength,
char * aDest,
PRInt32 * aDestLength)
{
nsresult res;
if (mHelper == nsnull) {
res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,
kIUnicodeEncodeHelperIID, (void**) & mHelper);
if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER;
}
res = mHelper->ConvertByTable(aSrc, aSrcLength, aDest, aDestLength,
mShiftTable, mMappingTable);
return res;
}
//----------------------------------------------------------------------
// Class nsTablesEncoderSupport [implementation]
nsTablesEncoderSupport::nsTablesEncoderSupport(PRInt32 aTableCount,
uShiftTable ** aShiftTable,
uMappingTable ** aMappingTable)
: nsEncoderSupport()
{
mHelper = NULL;
mTableCount = aTableCount;
mShiftTable = aShiftTable;
mMappingTable = aMappingTable;
}
nsTablesEncoderSupport::~nsTablesEncoderSupport()
{
NS_IF_RELEASE(mHelper);
}
//----------------------------------------------------------------------
// Subclassing of nsEncoderSupport class [implementation]
NS_IMETHODIMP nsTablesEncoderSupport::ConvertNoBuffNoErr(
const PRUnichar * aSrc,
PRInt32 * aSrcLength,
char * aDest,
PRInt32 * aDestLength)
{
nsresult res;
if (mHelper == nsnull) {
res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,
kIUnicodeEncodeHelperIID, (void**) & mHelper);
if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER;
}
res = mHelper->ConvertByTables(aSrc, aSrcLength, aDest, aDestLength,
mTableCount, mShiftTable, mMappingTable);
return res;
}
//----------------------------------------------------------------------
// Class nsDecoderSupport [implementation]
nsDecoderSupport::nsDecoderSupport()
{
mBufferCapacity = DEFAULT_BUFFER_CAPACITY;
mBuffer = new char[mBufferCapacity];
Reset();
NS_INIT_REFCNT();
PR_AtomicIncrement(&g_InstanceCount);
}
nsDecoderSupport::~nsDecoderSupport()
{
delete [] mBuffer;
PR_AtomicDecrement(&g_InstanceCount);
}
void nsDecoderSupport::FillBuffer(const char ** aSrc, PRInt32 aSrcLength)
{
PRInt32 bcr = PR_MIN(mBufferCapacity - mBufferLength, aSrcLength);
memcpy(mBuffer + mBufferLength, *aSrc, bcr);
mBufferLength += bcr;
(*aSrc) += bcr;
}
void nsDecoderSupport::DoubleBuffer()
{
mBufferCapacity *= 2;
char * newBuffer = new char [mBufferCapacity];
if (mBufferLength > 0) memcpy(newBuffer, mBuffer, mBufferLength);
delete [] mBuffer;
mBuffer = newBuffer;
}
//----------------------------------------------------------------------
// Interface nsISupports [implementation]
NS_IMPL_ADDREF(nsDecoderSupport);
NS_IMPL_RELEASE(nsDecoderSupport);
nsresult nsDecoderSupport::QueryInterface(REFNSIID aIID,
void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtr = NULL;
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kIUnicodeDecoderIID)) {
*aInstancePtr = (void*) ((nsIUnicodeDecoder*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) ((nsISupports*)this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
//----------------------------------------------------------------------
// Interface nsIUnicodeDecoder [implementation]
NS_IMETHODIMP nsDecoderSupport::Convert(const char * aSrc,
PRInt32 * aSrcLength,
PRUnichar * aDest,
PRInt32 * aDestLength)
{
// we do all operations using pointers internally
const char * src = aSrc;
const char * srcEnd = aSrc + *aSrcLength;
PRUnichar * dest = aDest;
PRUnichar * destEnd = aDest + *aDestLength;
PRInt32 bcr, bcw; // byte counts for read & write;
nsresult res = NS_OK;
// do we have some residual data from the last conversion?
if (mBufferLength > 0) if (dest == destEnd) {
res = NS_OK_UDEC_MOREOUTPUT;
} else for (;;) {
// we need new data to add to the buffer
if (src == srcEnd) {
res = NS_OK_UDEC_MOREINPUT;
break;
}
// fill that buffer
PRInt32 buffLen = mBufferLength; // initial buffer length
FillBuffer(&src, srcEnd - src);
// convert that buffer
bcr = mBufferLength;
bcw = destEnd - dest;
res = ConvertNoBuff(mBuffer, &bcr, dest, &bcw);
dest += bcw;
if ((res == NS_OK_UDEC_MOREINPUT) && (bcw == 0)) {
// not enough input to convert even a single char: repeat!
DoubleBuffer();
} else {
if (bcr < buffLen) {
// we didn't convert that residual data - unfill the buffer
src -= mBufferLength - buffLen;
mBufferLength = buffLen;
} else {
// the buffer and some extra data was converted - unget the rest
src -= mBufferLength - bcr;
mBufferLength = 0;
}
break;
}
}
if (res == NS_OK) {
bcr = srcEnd - src;
bcw = destEnd - dest;
res = ConvertNoBuff(src, &bcr, dest, &bcw);
src += bcr;
dest += bcw;
// if we have partial input, store it in our internal buffer.
if (res == NS_OK_UDEC_MOREINPUT) {
bcr = srcEnd - src;
// make sure buffer is large enough
while (bcr > mBufferCapacity) DoubleBuffer();
FillBuffer(&src, bcr);
}
}
*aSrcLength -= srcEnd - src;
*aDestLength -= destEnd - dest;
return res;
}
NS_IMETHODIMP nsDecoderSupport::Reset()
{
mBufferLength = 0;
return NS_OK;
}
NS_IMETHODIMP nsDecoderSupport::Convert(PRUnichar * aDest,
PRInt32 aDestOffset,
PRInt32 * aDestLength,
const char * aSrc,
PRInt32 aSrcOffset,
PRInt32 * aSrcLength)
{
// XXX deprecated
return Convert(aSrc + aSrcOffset, aSrcLength, aDest + aDestOffset,
aDestLength);
}
NS_IMETHODIMP nsDecoderSupport::Finish(PRUnichar * aDest, PRInt32 aDestOffset,
PRInt32 * aDestLength)
{
// XXX deprecated
return NS_OK;
}
NS_IMETHODIMP nsDecoderSupport::Length(const char * aSrc, PRInt32 aSrcOffset,
PRInt32 aSrcLength, PRInt32 * aDestLength)
{
// XXX deprecated
return GetMaxLength(aSrc + aSrcOffset, aSrcLength, aDestLength);
}
NS_IMETHODIMP nsDecoderSupport::SetInputErrorBehavior(PRInt32 aBehavior)
{
// XXX deprecated
return NS_OK;
}
//----------------------------------------------------------------------
// Class nsTableDecoderSupport [implementation]
nsTableDecoderSupport::nsTableDecoderSupport(uShiftTable * aShiftTable,
uMappingTable * aMappingTable)
: nsDecoderSupport()
{
mHelper = NULL;
mShiftTable = aShiftTable;
mMappingTable = aMappingTable;
}
nsTableDecoderSupport::~nsTableDecoderSupport()
{
NS_IF_RELEASE(mHelper);
}
//----------------------------------------------------------------------
// Subclassing of nsDecoderSupport class [implementation]
NS_IMETHODIMP nsTableDecoderSupport::ConvertNoBuff(const char * aSrc,
PRInt32 * aSrcLength,
PRUnichar * aDest,
PRInt32 * aDestLength)
{
nsresult res;
if (mHelper == nsnull) {
res = nsComponentManager::CreateInstance(kUnicodeDecodeHelperCID, NULL,
kIUnicodeDecodeHelperIID, (void**) & mHelper);
if (NS_FAILED(res)) return NS_ERROR_UDEC_NOHELPER;
}
res = mHelper->ConvertByTable(aSrc, aSrcLength, aDest, aDestLength,
mShiftTable, mMappingTable);
return res;
}
//----------------------------------------------------------------------
// Class nsTablesDecoderSupport [implementation]
nsTablesDecoderSupport::nsTablesDecoderSupport(PRInt32 aTableCount,
uRange * aRangeArray,
uShiftTable ** aShiftTable,
uMappingTable ** aMappingTable)
: nsDecoderSupport()
{
mHelper = NULL;
mTableCount = aTableCount;
mRangeArray = aRangeArray;
mShiftTable = aShiftTable;
mMappingTable = aMappingTable;
}
nsTablesDecoderSupport::~nsTablesDecoderSupport()
{
NS_IF_RELEASE(mHelper);
}
//----------------------------------------------------------------------
// Subclassing of nsDecoderSupport class [implementation]
NS_IMETHODIMP nsTablesDecoderSupport::ConvertNoBuff(const char * aSrc,
PRInt32 * aSrcLength,
PRUnichar * aDest,
PRInt32 * aDestLength)
{
nsresult res;
if (mHelper == nsnull) {
res = nsComponentManager::CreateInstance(kUnicodeDecodeHelperCID, NULL,
kIUnicodeDecodeHelperIID, (void**) & mHelper);
if (NS_FAILED(res)) return NS_ERROR_UDEC_NOHELPER;
}
res = mHelper->ConvertByTables(aSrc, aSrcLength, aDest, aDestLength,
mTableCount, mRangeArray, mShiftTable, mMappingTable);
return res;
}

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

@ -0,0 +1,333 @@
/* -*- 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 nsUCvCnSupport_h___
#define nsUCvCnSupport_h___
#include "nsIUnicodeEncoder.h"
#include "nsIUnicodeDecoder.h"
#include "nsIUnicodeEncodeHelper.h"
#include "nsIUnicodeDecodeHelper.h"
//----------------------------------------------------------------------
// Class nsEncoderSupport [declaration]
/**
* Support class for the Unicode encoders.
*
* The class source files for this class are in /ucvlatin/nsUCvLatinSupport.
* However, because these objects requires non-xpcom subclassing, local copies
* will be made into the other directories using them. Just don't forget to
* keep in sync with the master copy!
*
* This class implements:
* - nsISupports
* - the buffer management
* - error handling procedure(s)
*
* @created 17/Feb/1999
* @author Catalin Rotaru [CATA]
*/
class nsEncoderSupport : public nsIUnicodeEncoder
{
NS_DECL_ISUPPORTS
protected:
/**
* Internal buffer for partial conversions.
*/
char * mBuffer;
PRInt32 mBufferCapacity;
char * mBufferStart;
char * mBufferEnd;
/**
* Error handling stuff
*/
PRInt32 mErrBehavior;
nsIUnicharEncoder * mErrEncoder;
PRUnichar mErrChar;
/**
* Convert method but *without* the buffer management stuff and *with*
* error handling stuff.
*/
NS_IMETHOD ConvertNoBuff(const PRUnichar * aSrc, PRInt32 * aSrcLength,
char * aDest, PRInt32 * aDestLength);
/**
* Convert method but *without* the buffer management stuff and *without*
* error handling stuff.
*/
NS_IMETHOD ConvertNoBuffNoErr(const PRUnichar * aSrc, PRInt32 * aSrcLength,
char * aDest, PRInt32 * aDestLength) = 0;
/**
* Finish method but *without* the buffer management stuff.
*/
NS_IMETHOD FinishNoBuff(char * aDest, PRInt32 * aDestLength);
/**
* Copy as much as possible from the internal buffer to the destination.
*/
nsresult FlushBuffer(char ** aDest, const char * aDestEnd);
public:
/**
* Class constructor.
*/
nsEncoderSupport();
/**
* Class destructor.
*/
virtual ~nsEncoderSupport();
//--------------------------------------------------------------------
// Interface nsIUnicodeEncoder [declaration]
NS_IMETHOD Convert(const PRUnichar * aSrc, PRInt32 * aSrcLength,
char * aDest, PRInt32 * aDestLength);
NS_IMETHOD Finish(char * aDest, PRInt32 * aDestLength);
NS_IMETHOD Reset();
NS_IMETHOD SetOutputErrorBehavior(PRInt32 aBehavior,
nsIUnicharEncoder * aEncoder, PRUnichar aChar);
};
//----------------------------------------------------------------------
// Class nsTableEncoderSupport [declaration]
/**
* Support class for a single-table-driven Unicode encoder.
*
* @created 17/Feb/1999
* @author Catalin Rotaru [CATA]
*/
class nsTableEncoderSupport : public nsEncoderSupport
{
public:
/**
* Class constructor.
*/
nsTableEncoderSupport(uShiftTable * aShiftTable,
uMappingTable * aMappingTable);
/**
* Class destructor.
*/
virtual ~nsTableEncoderSupport();
protected:
nsIUnicodeEncodeHelper * mHelper; // encoder helper object
uShiftTable * mShiftTable;
uMappingTable * mMappingTable;
//--------------------------------------------------------------------
// Subclassing of nsEncoderSupport class [declaration]
NS_IMETHOD ConvertNoBuffNoErr(const PRUnichar * aSrc, PRInt32 * aSrcLength,
char * aDest, PRInt32 * aDestLength);
};
//----------------------------------------------------------------------
// Class nsTablesEncoderSupport [declaration]
/**
* Support class for a multi-table-driven Unicode encoder.
*
* @created 11/Mar/1999
* @author Catalin Rotaru [CATA]
*/
class nsTablesEncoderSupport : public nsEncoderSupport
{
public:
/**
* Class constructor.
*/
nsTablesEncoderSupport(PRInt32 aTableCount, uShiftTable ** aShiftTable,
uMappingTable ** aMappingTable);
/**
* Class destructor.
*/
virtual ~nsTablesEncoderSupport();
protected:
nsIUnicodeEncodeHelper * mHelper; // encoder helper object
PRInt32 mTableCount;
uShiftTable ** mShiftTable;
uMappingTable ** mMappingTable;
//--------------------------------------------------------------------
// Subclassing of nsEncoderSupport class [declaration]
NS_IMETHOD ConvertNoBuffNoErr(const PRUnichar * aSrc, PRInt32 * aSrcLength,
char * aDest, PRInt32 * aDestLength);
};
//----------------------------------------------------------------------
// Class nsDecoderSupport [declaration]
/**
* Support class for the Unicode decoders.
*
* This class implements:
* - nsISupports
* - the buffer management
*
* @created 15/Mar/1999
* @author Catalin Rotaru [CATA]
*/
class nsDecoderSupport : public nsIUnicodeDecoder
{
NS_DECL_ISUPPORTS
protected:
/**
* Internal buffer for partial conversions.
*/
char * mBuffer;
PRInt32 mBufferCapacity;
PRInt32 mBufferLength;
/**
* Convert method but *without* the buffer management stuff.
*/
NS_IMETHOD ConvertNoBuff(const char * aSrc, PRInt32 * aSrcLength,
PRUnichar * aDest, PRInt32 * aDestLength) = 0;
void FillBuffer(const char ** aSrc, PRInt32 aSrcLength);
void DoubleBuffer();
public:
/**
* Class constructor.
*/
nsDecoderSupport();
/**
* Class destructor.
*/
virtual ~nsDecoderSupport();
//--------------------------------------------------------------------
// Interface nsIUnicodeDecoder [declaration]
NS_IMETHOD Convert(const char * aSrc, PRInt32 * aSrcLength,
PRUnichar * aDest, PRInt32 * aDestLength);
NS_IMETHOD GetMaxLength(const char * aSrc, PRInt32 aSrcLength,
PRInt32 * aDestLength) = 0;
NS_IMETHOD Reset();
// XXX deprecated methods - to go away when interface change.
NS_IMETHOD Convert(PRUnichar * aDest, PRInt32 aDestOffset,
PRInt32 * aDestLength, const char * aSrc, PRInt32 aSrcOffset,
PRInt32 * aSrcLength);
NS_IMETHOD Finish(PRUnichar * aDest, PRInt32 aDestOffset,
PRInt32 * aDestLength);
NS_IMETHOD Length(const char * aSrc, PRInt32 aSrcOffset,
PRInt32 aSrcLength, PRInt32 * aDestLength);
NS_IMETHOD SetInputErrorBehavior(PRInt32 aBehavior);
};
//----------------------------------------------------------------------
// Class nsTableDecoderSupport [declaration]
/**
* Support class for a single-table-driven Unicode decoder.
*
* @created 15/Mar/1999
* @author Catalin Rotaru [CATA]
*/
class nsTableDecoderSupport : public nsDecoderSupport
{
public:
/**
* Class constructor.
*/
nsTableDecoderSupport(uShiftTable * aShiftTable,
uMappingTable * aMappingTable);
/**
* Class destructor.
*/
virtual ~nsTableDecoderSupport();
protected:
nsIUnicodeDecodeHelper * mHelper; // decoder helper object
uShiftTable * mShiftTable;
uMappingTable * mMappingTable;
//--------------------------------------------------------------------
// Subclassing of nsDecoderSupport class [declaration]
NS_IMETHOD ConvertNoBuff(const char * aSrc, PRInt32 * aSrcLength,
PRUnichar * aDest, PRInt32 * aDestLength);
};
//----------------------------------------------------------------------
// Class nsTablesDecoderSupport [declaration]
/**
* Support class for a multi-table-driven Unicode decoder.
*
* @created 24/Mar/1999
* @author Catalin Rotaru [CATA]
*/
class nsTablesDecoderSupport : public nsDecoderSupport
{
public:
/**
* Class constructor.
*/
nsTablesDecoderSupport(PRInt32 aTableCount, uRange * aRangeArray,
uShiftTable ** aShiftTable, uMappingTable ** aMappingTable);
/**
* Class destructor.
*/
virtual ~nsTablesDecoderSupport();
protected:
nsIUnicodeDecodeHelper * mHelper; // decoder helper object
PRInt32 mTableCount;
uRange * mRangeArray;
uShiftTable ** mShiftTable;
uMappingTable ** mMappingTable;
//--------------------------------------------------------------------
// Subclassing of nsDecoderSupport class [declaration]
NS_IMETHOD ConvertNoBuff(const char * aSrc, PRInt32 * aSrcLength,
PRUnichar * aDest, PRInt32 * aDestLength);
};
#endif /* nsUCvCnSupport_h___ */

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

@ -0,0 +1,58 @@
/* -*- 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 "nsUnicodeToBIG5.h"
//----------------------------------------------------------------------
// Global functions and data [declaration]
static PRUint16 g_BIG5MappingTable[] = {
#include "big5.uf"
};
static PRInt16 g_BIG5ShiftTable[] = {
1, u1ByteCharset ,
ShiftCell(0,0,0,0,0,0,0,0)
};
//----------------------------------------------------------------------
// Class nsUnicodeToBIG5 [implementation]
nsUnicodeToBIG5::nsUnicodeToBIG5()
: nsTableEncoderSupport((uShiftTable*) &g_BIG5ShiftTable,
(uMappingTable*) &g_BIG5MappingTable)
{
}
nsresult nsUnicodeToBIG5::CreateInstance(nsISupports ** aResult)
{
*aResult = new nsUnicodeToBIG5();
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
}
//----------------------------------------------------------------------
// Subclassing of nsTableEncoderSupport class [implementation]
NS_IMETHODIMP nsUnicodeToBIG5::GetMaxLength(const PRUnichar * aSrc,
PRInt32 aSrcLength,
PRInt32 * aDestLength)
{
*aDestLength = aSrcLength;
return NS_OK_UENC_EXACTLENGTH;
}

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

@ -0,0 +1,57 @@
/* -*- 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 nsUnicodeToBIG5_h___
#define nsUnicodeToBIG5_h___
#include "nsUCvCnSupport.h"
//----------------------------------------------------------------------
// Class nsUnicodeToBIG5 [declaration]
/**
* A character set converter from Unicode to BIG5.
*
* @created 06/Apr/1999
* @author Catalin Rotaru [CATA]
*/
class nsUnicodeToBIG5 : public nsTableEncoderSupport
{
public:
/**
* Class constructor.
*/
nsUnicodeToBIG5();
/**
* 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 /* nsUnicodeToBIG5_h___ */