зеркало из https://github.com/mozilla/pjs.git
add ucvlatin, add cp1253, iso-8859-1, windows-1253 converter, change the nsIUnicodeDecodeUtil interface
This commit is contained in:
Родитель
0a67f88e29
Коммит
6da5d16514
|
@ -18,6 +18,7 @@
|
|||
DEPTH=..\..
|
||||
|
||||
DIRS=public src \
|
||||
ucvlatin \
|
||||
ucvja \
|
||||
tests
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
|
||||
#include "nsISupports.h"
|
||||
|
||||
// Class ID for our Ascii2Unicode charset converter
|
||||
// Class ID for our Latin1ToUnicode charset converter
|
||||
// {A3254CB0-8E20-11d2-8A98-00600811A836}
|
||||
NS_DECLARE_ID(kAscii2UnicodeCID,
|
||||
NS_DECLARE_ID(kLatin1ToUnicodeCID,
|
||||
0xa3254cb0, 0x8e20, 0x11d2, 0x8a, 0x98, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36);
|
||||
|
||||
#endif /* nsConverterCID_h___ */
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#ifndef nsICharsetConverterInfo_h___
|
||||
#define nsICharsetConverterInfo_h___
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
// Interface ID for our Converter Information interface
|
||||
|
@ -50,14 +49,14 @@ public:
|
|||
*
|
||||
* @param aCharset [OUT] a name/alias for the source charset
|
||||
*/
|
||||
NS_IMETHOD GetCharsetSrc(nsString ** aCharset) = 0;
|
||||
NS_IMETHOD GetCharsetSrc(char ** aCharset) = 0;
|
||||
|
||||
/**
|
||||
* Returns the character set this converter is converting into.
|
||||
*
|
||||
* @param aCharset [OUT] a name/alias for the destination charset
|
||||
*/
|
||||
NS_IMETHOD GetCharsetDest(nsString ** aCharset) = 0;
|
||||
NS_IMETHOD GetCharsetDest(char ** aCharset) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsICharsetConverterInfo_h___ */
|
||||
|
|
|
@ -31,28 +31,57 @@ NS_DECLARE_ID ( kIUnicodeDecodeUtilIID,
|
|||
class nsIUnicodeDecodeUtil : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_IMETHOD ConvertBy1Table(
|
||||
/*
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Convert(
|
||||
PRUnichar *aDest,
|
||||
PRInt32 aDestOffset,
|
||||
PRInt32 *aDestLength,
|
||||
const char *aSrc,
|
||||
PRInt32 aSrcOffset,
|
||||
PRInt32 *aSrcLength,
|
||||
PRInt32 aBehavior,
|
||||
uShiftTable *aShiftTable,
|
||||
uMappingTable *aMappingTable
|
||||
) = 0;
|
||||
|
||||
NS_IMETHOD ConvertByNTable(
|
||||
/*
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Convert(
|
||||
PRUnichar *aDest,
|
||||
PRInt32 aDestOffset,
|
||||
PRInt32 *aDestLength,
|
||||
const char *aSrc,
|
||||
PRInt32 aSrcOffset,
|
||||
PRInt32 *aSrcLength,
|
||||
PRInt32 aBehavior,
|
||||
PRUint16 numOfTable,
|
||||
uRange *aRangeArray,
|
||||
uShiftTable *aShiftTableArray,
|
||||
uMappingTable *aMappingTableArray
|
||||
) = 0;
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Init1ByteFastTable(
|
||||
uMappingTable *aMappingTable,
|
||||
PRUnichar *aFastTable
|
||||
) = 0;
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Convert(
|
||||
PRUnichar *aDest,
|
||||
PRInt32 aDestOffset,
|
||||
PRInt32 *aDestLength,
|
||||
const char *aSrc,
|
||||
PRInt32 aSrcOffset,
|
||||
PRInt32 *aSrcLength,
|
||||
const PRUnichar *aFastTable
|
||||
) = 0;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -28,14 +28,12 @@ DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
|||
|
||||
CPPSRCS = \
|
||||
nsCharsetConverterManager.cpp \
|
||||
nsAscii2Unicode.cpp \
|
||||
nsUnicodeDecodeUtil.cpp \
|
||||
nsUConvDll.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsCharsetConverterManager.obj \
|
||||
.\$(OBJDIR)\nsAscii2Unicode.obj \
|
||||
.\$(OBJDIR)\nsUnicodeDecodeUtil.obj \
|
||||
.\$(OBJDIR)\nsUConvDll.obj \
|
||||
$(NULL)
|
||||
|
@ -59,8 +57,8 @@ LINCS= \
|
|||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\uconv \
|
||||
# the following lines are hacks
|
||||
-I$(PUBLIC)\ucvja \
|
||||
-I..\ucvja \
|
||||
-I..\ucvlatin \
|
||||
$(NULL)
|
||||
|
||||
LLIBS= \
|
||||
|
|
|
@ -72,6 +72,7 @@ struct ConverterInfo
|
|||
* XXX What happens in a multithreaded environment?!
|
||||
* XXX Make this a service; use the service manager; etc.
|
||||
* XXX Have a clear and consistent extensibility model.
|
||||
* XXX Charset names are case-insensitive!
|
||||
*
|
||||
* @created 17/Nov/1998
|
||||
* @author Catalin Rotaru [CATA]
|
||||
|
@ -209,7 +210,6 @@ nsresult nsCharsetConverterManager::CreateMapping()
|
|||
// slots.
|
||||
nsresult nsCharsetConverterManager::CreateConvertersList()
|
||||
{
|
||||
|
||||
#include "registryhack2.h"
|
||||
|
||||
return NS_OK;
|
||||
|
@ -225,7 +225,9 @@ nsresult nsCharsetConverterManager::GatherConvertersInfo()
|
|||
info = GetICharsetConverterInfo(mEncArray, i, &mEncSize);
|
||||
if (info == NULL) continue;
|
||||
|
||||
info->GetCharsetDest(&str);
|
||||
char *charset;
|
||||
info->GetCharsetDest(&charset);
|
||||
str = new nsString(charset);
|
||||
GetCharsetName(str,&mEncArray[i].mCharset);
|
||||
delete str;
|
||||
|
||||
|
@ -236,7 +238,9 @@ nsresult nsCharsetConverterManager::GatherConvertersInfo()
|
|||
info = GetICharsetConverterInfo(mDecArray, i, &mDecSize);
|
||||
if (info == NULL) continue;
|
||||
|
||||
info->GetCharsetSrc(&str);
|
||||
char *charset;
|
||||
info->GetCharsetSrc(&charset);
|
||||
str = new nsString(charset);
|
||||
GetCharsetName(str,&mDecArray[i].mCharset);
|
||||
delete str;
|
||||
|
||||
|
|
|
@ -19,11 +19,7 @@
|
|||
|
||||
#include "nsRepository.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsCharsetConverterManager.h"
|
||||
#include "nsAscii2Unicode.h"
|
||||
#include "nsConverterCID.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Global functions and data [declaration]
|
||||
|
@ -59,20 +55,6 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID,
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
// the Ascii2Unicode converter
|
||||
if (aCID.Equals(kAscii2UnicodeCID)) {
|
||||
nsAscii2UnicodeFactory *factory = new nsAscii2UnicodeFactory();
|
||||
nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
*aFactory = NULL;
|
||||
delete factory;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
@ -80,12 +62,6 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(const char * path)
|
|||
{
|
||||
nsresult res;
|
||||
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
res = nsRepository::RegisterFactory(kAscii2UnicodeCID, path,
|
||||
PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
res = nsRepository::RegisterFactory(kCharsetConverterManagerCID, path,
|
||||
PR_TRUE, PR_TRUE);
|
||||
return res;
|
||||
|
@ -95,9 +71,6 @@ extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char * path)
|
|||
{
|
||||
nsresult res;
|
||||
|
||||
res = nsRepository::UnregisterFactory(kAscii2UnicodeCID, path);
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
res = nsRepository::UnregisterFactory(kCharsetConverterManagerCID, path);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -40,30 +40,33 @@ nsUnicodeDecodeUtil::~nsUnicodeDecodeUtil()
|
|||
}
|
||||
|
||||
#ifdef NO_OPTIMIZATION_FOR_1TABLE
|
||||
NS_IMETHODIMP nsUnicodeDecodeUtil::ConvertBy1Table(
|
||||
NS_IMETHODIMP nsUnicodeDecodeUtil::Convert(
|
||||
PRUnichar *aDest,
|
||||
PRInt32 aDestOffset,
|
||||
PRInt32 *aDestLength,
|
||||
const char *aSrc,
|
||||
PRInt32 aSrcOffset,
|
||||
PRInt32 *aSrcLength,
|
||||
PRInt32 aBehavior,
|
||||
uShiftTable *aShiftTable,
|
||||
uMappingTable *aMappingTable
|
||||
)
|
||||
{
|
||||
uRange range = {0x00, 0xff};
|
||||
return ConvertByNTable(aDest, aDestOffset, aDestLength, aSrc, aSrcOffset, aSrcLength,
|
||||
1, &range,
|
||||
return Convert(aDest, aDestOffset, aDestLength,
|
||||
aSrc, aSrcOffset, aSrcLength,
|
||||
aBehavior, 1, &range,
|
||||
aShiftTable, aMappingTable);
|
||||
}
|
||||
#else
|
||||
NS_IMETHODIMP nsUnicodeDecodeUtil::ConvertBy1Table(
|
||||
NS_IMETHODIMP nsUnicodeDecodeUtil::Convert(
|
||||
PRUnichar *aDest,
|
||||
PRInt32 aDestOffset,
|
||||
PRInt32 *aDestLength,
|
||||
const char *aSrc,
|
||||
PRInt32 aSrcOffset,
|
||||
PRInt32 *aSrcLength,
|
||||
PRInt32 aBehavior,
|
||||
uShiftTable *aShiftTable,
|
||||
uMappingTable *aMappingTable
|
||||
)
|
||||
|
@ -83,10 +86,12 @@ NS_IMETHODIMP nsUnicodeDecodeUtil::ConvertBy1Table(
|
|||
if(uScan(aShiftTable, (PRInt32*) 0, src, &med, srclen, &scanlen)) {
|
||||
uMapCode((uTable*) aMappingTable,med, dest);
|
||||
if(*dest == NOMAPPING) {
|
||||
//------
|
||||
// Fallback handling - need to change
|
||||
//------
|
||||
// ERROR_ILLEGAL_INPUT
|
||||
if(nsIUnicodeDecoder::kOnError_Signal == aBehavior)
|
||||
{
|
||||
*aSrcLength -= srclen;
|
||||
*aDestLength = validlen;
|
||||
return NS_ERROR_ILLEGAL_INPUT;
|
||||
}
|
||||
if(scanlen == 0)
|
||||
scanlen = 1;
|
||||
}
|
||||
|
@ -105,13 +110,14 @@ NS_IMETHODIMP nsUnicodeDecodeUtil::ConvertBy1Table(
|
|||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP nsUnicodeDecodeUtil::ConvertByNTable(
|
||||
NS_IMETHODIMP nsUnicodeDecodeUtil::Convert(
|
||||
PRUnichar *aDest,
|
||||
PRInt32 aDestOffset,
|
||||
PRInt32 *aDestLength,
|
||||
const char *aSrc,
|
||||
PRInt32 aSrcOffset,
|
||||
PRInt32 *aSrcLength,
|
||||
PRInt32 aBehavior,
|
||||
PRUint16 numberOfTable,
|
||||
uRange *aRangeArray,
|
||||
uShiftTable *aShiftTableArray,
|
||||
|
@ -147,10 +153,12 @@ NS_IMETHODIMP nsUnicodeDecodeUtil::ConvertByNTable(
|
|||
}
|
||||
}
|
||||
if(i == numberOfTable) {
|
||||
//------
|
||||
// Fallback handling - need to change
|
||||
//------
|
||||
// ERROR_ILLEGAL_INPUT
|
||||
if(nsIUnicodeDecoder::kOnError_Signal == aBehavior)
|
||||
{
|
||||
*aSrcLength -= srclen;
|
||||
*aDestLength = validlen;
|
||||
return NS_ERROR_ILLEGAL_INPUT;
|
||||
}
|
||||
if(scanlen == 0)
|
||||
scanlen = 1;
|
||||
*dest= NOMAPPING;
|
||||
|
@ -164,3 +172,54 @@ NS_IMETHODIMP nsUnicodeDecodeUtil::ConvertByNTable(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsUnicodeDecodeUtil::Init1ByteFastTable(
|
||||
uMappingTable *aMappingTable,
|
||||
PRUnichar *aFastTable
|
||||
)
|
||||
{
|
||||
static PRInt16 g1ByteShiftTable[] = {
|
||||
0, u1ByteCharset,
|
||||
ShiftCell(0, 0,0,0,0,0,0,0),
|
||||
};
|
||||
static char dmy[256];
|
||||
static PRBool init=PR_FALSE;
|
||||
if(! init)
|
||||
{
|
||||
for(int i= 0;i < 256; i++)
|
||||
dmy[i] = (char) dmy;
|
||||
init = PR_TRUE;
|
||||
}
|
||||
PRInt32 dm1 = 256;
|
||||
PRInt32 dm2 = 256;
|
||||
return Convert(aFastTable, 0, &dm1, dmy, 0, &dm2,
|
||||
nsIUnicodeDecoder::kOnError_Recover,
|
||||
(uShiftTable*) &g1ByteShiftTable, aMappingTable);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeDecodeUtil::Convert(
|
||||
PRUnichar *aDest,
|
||||
PRInt32 aDestOffset,
|
||||
PRInt32 *aDestLength,
|
||||
const char *aSrc,
|
||||
PRInt32 aSrcOffset,
|
||||
PRInt32 *aSrcLength,
|
||||
const PRUnichar *aFastTable
|
||||
)
|
||||
{
|
||||
PRUnichar *pD = aDest + aDestOffset;
|
||||
unsigned char *pS = (unsigned char*) (aSrc + aSrcOffset);
|
||||
PRInt32 srclen = *aSrcLength;
|
||||
PRInt32 destlen = *aDestLength;
|
||||
|
||||
for( ; ((srclen > 0) && ( destlen > 0)); srclen--, destlen--)
|
||||
*pD++ = aFastTable[*pS++];
|
||||
|
||||
*aSrcLength -= srclen;
|
||||
*aDestLength -= destlen;
|
||||
|
||||
if(srclen > 0)
|
||||
return NS_PARTIAL_MORE_OUTPUT;
|
||||
else
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -41,29 +41,46 @@ public:
|
|||
~nsUnicodeDecodeUtil();
|
||||
|
||||
public:
|
||||
NS_IMETHOD ConvertBy1Table(
|
||||
NS_IMETHOD Convert(
|
||||
PRUnichar *aDest,
|
||||
PRInt32 aDestOffset,
|
||||
PRInt32 *aDestLength,
|
||||
const char *aSrc,
|
||||
PRInt32 aSrcOffset,
|
||||
PRInt32 *aSrcLength,
|
||||
PRInt32 aBehavior,
|
||||
uShiftTable *aShiftTable,
|
||||
uMappingTable *aMappingTable
|
||||
);
|
||||
|
||||
NS_IMETHOD ConvertByNTable(
|
||||
NS_IMETHOD Convert(
|
||||
PRUnichar *aDest,
|
||||
PRInt32 aDestOffset,
|
||||
PRInt32 *aDestLength,
|
||||
const char *aSrc,
|
||||
PRInt32 aSrcOffset,
|
||||
PRInt32 *aSrcLength,
|
||||
PRInt32 aBehavior,
|
||||
PRUint16 numOfTable,
|
||||
uRange *aRangeArray,
|
||||
uShiftTable *aShiftTableArray,
|
||||
uMappingTable *aMappingTableArray
|
||||
);
|
||||
|
||||
NS_IMETHOD Init1ByteFastTable(
|
||||
uMappingTable *aMappingTable,
|
||||
PRUnichar *aFastTable
|
||||
);
|
||||
|
||||
NS_IMETHOD Convert(
|
||||
PRUnichar *aDest,
|
||||
PRInt32 aDestOffset,
|
||||
PRInt32 *aDestLength,
|
||||
const char *aSrc,
|
||||
PRInt32 aSrcOffset,
|
||||
PRInt32 *aSrcLength,
|
||||
const PRUnichar *aFastTable
|
||||
);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,5 +21,6 @@
|
|||
|
||||
#include "nsConverterCID.h"
|
||||
#include "nsUCVJACID.h"
|
||||
#include "nsUCvLatinCID.h"
|
||||
|
||||
#endif /* __REGISTRYHACK1_H__ */
|
||||
|
|
|
@ -17,11 +17,13 @@
|
|||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
mDecSize = 2;
|
||||
mDecSize = 4;
|
||||
mDecArray = new ConverterInfo [mDecSize];
|
||||
|
||||
mDecArray[0].mCID = &kAscii2UnicodeCID;
|
||||
mDecArray[0].mCID = &kLatin1ToUnicodeCID;
|
||||
mDecArray[1].mCID = &kSJIS2UnicodeCID;
|
||||
mDecArray[2].mCID = &kISO88597ToUnicodeCID;
|
||||
mDecArray[3].mCID = &kCP1253ToUnicodeCID;
|
||||
|
||||
mEncSize = 0;
|
||||
mEncArray = NULL;
|
||||
|
|
|
@ -39,8 +39,8 @@ OBJS = \
|
|||
LINCS= \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\uconv \
|
||||
-I$(PUBLIC)\ucvja \
|
||||
-I..\public \
|
||||
-I..\ucvja \
|
||||
$(NULL)
|
||||
|
||||
LLIBS= \
|
||||
|
|
|
@ -24,36 +24,27 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsConverterCID.h"
|
||||
|
||||
#define TEST_SJIS
|
||||
#ifdef TEST_SJIS
|
||||
#include "nsUCVJACID.h"
|
||||
|
||||
#ifdef XP_UNIX
|
||||
|
||||
#define UCONV_DLL "libuconv.so"
|
||||
#define UCVLATIN_DLL "libucvlatin.so"
|
||||
#define UCVJA_DLL "libucvja.so"
|
||||
#else
|
||||
#else /* XP_UNIX */
|
||||
#ifdef XP_MAC
|
||||
#define UCONV_DLL "UCONV_DLL"
|
||||
#define UCVLATIN_DLL "UCVLATIN_DLL"
|
||||
#define UCVJA_DLL "UCVJA_DLL"
|
||||
#else /* XP_MAC */
|
||||
#define UCONV_DLL "uconv.dll"
|
||||
#define UCVLATIN_DLL "ucvlatin.dll"
|
||||
#define UCVJA_DLL "ucvja.dll"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef XP_UNIX
|
||||
#define UCONV_DLL "libuconv.so"
|
||||
#else
|
||||
#ifdef XP_MAC
|
||||
#define UCONV_DLL "UCONV_DLL"
|
||||
#else /* XP_MAC */
|
||||
#define UCONV_DLL "uconv.dll"
|
||||
#endif
|
||||
#endif
|
||||
#define TABLE_SIZE1 5
|
||||
|
||||
|
||||
nsICharsetConverterManager * ccMan = NULL;
|
||||
|
||||
nsresult setupRegistry()
|
||||
|
@ -63,15 +54,13 @@ nsresult setupRegistry()
|
|||
res = nsRepository::RegisterFactory(kCharsetConverterManagerCID, UCONV_DLL, PR_FALSE, PR_FALSE);
|
||||
if (NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res;
|
||||
|
||||
res = nsRepository::RegisterFactory(kAscii2UnicodeCID, UCONV_DLL, PR_FALSE, PR_FALSE);
|
||||
|
||||
#ifdef TEST_SJIS
|
||||
res = nsRepository::RegisterFactory(kLatin1ToUnicodeCID, UCVLATIN_DLL, PR_FALSE, PR_FALSE);
|
||||
if (NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res;
|
||||
|
||||
res = nsRepository::RegisterFactory(kSJIS2UnicodeCID, UCVJA_DLL, PR_FALSE, PR_FALSE);
|
||||
#endif
|
||||
if (NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res;
|
||||
|
||||
return res;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult init()
|
||||
|
@ -79,7 +68,7 @@ nsresult init()
|
|||
nsresult res;
|
||||
|
||||
res = setupRegistry();
|
||||
if (NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) {
|
||||
if (NS_FAILED(res)) {
|
||||
printf("Error setting up registry: 0x%x",res);
|
||||
return res;
|
||||
}
|
||||
|
@ -140,13 +129,13 @@ nsresult testCharsetConverterManager()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult testAsciiDecoder()
|
||||
nsresult testLatin1Decoder()
|
||||
{
|
||||
printf("\n[T2] Ascii2Unicode\n");
|
||||
printf("\n[T2] Latin1ToUnicode\n");
|
||||
|
||||
// create converter
|
||||
nsIUnicodeDecoder * dec;
|
||||
nsAutoString str("Ascii");
|
||||
nsAutoString str("iso-8859-1");
|
||||
nsresult res = ccMan->GetUnicodeDecoder(&str,&dec);
|
||||
if (NS_FAILED(res)) {
|
||||
printf("ERROR 0x%x: Cannot instantiate.\n",res);
|
||||
|
@ -187,7 +176,7 @@ nsresult testAsciiDecoder()
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
#ifdef TEST_SJIS
|
||||
|
||||
|
||||
#define SJIS_TEST_SRC_SIZE 40
|
||||
#define SJIS_TEST_DEST_SIZE 24
|
||||
|
@ -347,7 +336,6 @@ U+FF11 U+FF12 U+FF13 U+FF21 U+FF22 U+FF23
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
nsresult run()
|
||||
{
|
||||
nsresult res;
|
||||
|
@ -355,13 +343,8 @@ nsresult run()
|
|||
res = testCharsetConverterManager();
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
res = testAsciiDecoder();
|
||||
|
||||
#ifdef TEST_SJIS
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
res = testLatin1Decoder();
|
||||
res = testSJISDecoder();
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ OBJS = \
|
|||
$(NULL)
|
||||
|
||||
EXPORTS= \
|
||||
nsUCVJACID.h \
|
||||
$(NULL)
|
||||
|
||||
LINCS= \
|
||||
|
|
|
@ -81,6 +81,7 @@ public:
|
|||
NS_IMETHOD SetInputErrorBehavior(PRInt32 aBehavior);
|
||||
|
||||
private:
|
||||
PRInt32 mBehavior;
|
||||
nsIUnicodeDecodeUtil *mUtil;
|
||||
|
||||
};
|
||||
|
@ -108,6 +109,7 @@ nsSJIS2Unicode::nsSJIS2Unicode()
|
|||
NS_INIT_REFCNT();
|
||||
PR_AtomicIncrement(&g_InstanceCount);
|
||||
mUtil = nsnull;
|
||||
mBehavior = kOnError_Recover;
|
||||
}
|
||||
|
||||
nsSJIS2Unicode::~nsSJIS2Unicode()
|
||||
|
@ -142,8 +144,9 @@ NS_IMETHODIMP nsSJIS2Unicode::Convert(PRUnichar * aDest, PRInt32 aDestOffset,
|
|||
return res;
|
||||
}
|
||||
}
|
||||
return mUtil->ConvertBy1Table( aDest, aDestOffset, aDestLength,
|
||||
return mUtil->Convert( aDest, aDestOffset, aDestLength,
|
||||
aSrc, aSrcOffset, aSrcLength,
|
||||
mBehavior,
|
||||
(uShiftTable*) &gShiftTable,
|
||||
(uMappingTable*)&gMappingTable);
|
||||
}
|
||||
|
@ -161,7 +164,7 @@ NS_IMETHODIMP nsSJIS2Unicode::Length(const char * aSrc, PRInt32 aSrcOffset,
|
|||
PRInt32 * aDestLength)
|
||||
{
|
||||
*aDestLength = aSrcLength;
|
||||
return NS_EXACT_LENGTH;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSJIS2Unicode::Reset()
|
||||
|
@ -171,7 +174,7 @@ NS_IMETHODIMP nsSJIS2Unicode::Reset()
|
|||
|
||||
NS_IMETHODIMP nsSJIS2Unicode::SetInputErrorBehavior(PRInt32 aBehavior)
|
||||
{
|
||||
// no input error possible, this encoding is too simple
|
||||
mBehavior = aBehavior;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -257,14 +260,14 @@ NS_IMETHODIMP nsSJIS2UnicodeFactory::LockFactory(PRBool aLock)
|
|||
//----------------------------------------------------------------------
|
||||
// Interface nsICharsetConverterInfo [implementation]
|
||||
|
||||
NS_IMETHODIMP nsSJIS2UnicodeFactory::GetCharsetSrc(nsString ** aCharset)
|
||||
NS_IMETHODIMP nsSJIS2UnicodeFactory::GetCharsetSrc(char ** aCharset)
|
||||
{
|
||||
(*aCharset) = new nsString(NS_SRC_CHARSET);
|
||||
(*aCharset) = NS_SRC_CHARSET;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSJIS2UnicodeFactory::GetCharsetDest(nsString ** aCharset)
|
||||
NS_IMETHODIMP nsSJIS2UnicodeFactory::GetCharsetDest(char ** aCharset)
|
||||
{
|
||||
(*aCharset) = new nsString(NS_DEST_CHARSET);
|
||||
(*aCharset) = NS_DEST_CHARSET;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -57,8 +57,8 @@ public:
|
|||
//--------------------------------------------------------------------
|
||||
// Interface nsICharsetConverterInfo [declaration]
|
||||
|
||||
NS_IMETHOD GetCharsetSrc(nsString ** aCharset);
|
||||
NS_IMETHOD GetCharsetDest(nsString ** aCharset);
|
||||
NS_IMETHOD GetCharsetSrc(char ** aCharset);
|
||||
NS_IMETHOD GetCharsetDest(char ** aCharset);
|
||||
};
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче