This commit is contained in:
cata%netscape.com 1999-03-11 22:37:27 +00:00
Родитель d0c8035a37
Коммит 5f1af02b74
4 изменённых файлов: 116 добавлений и 6 удалений

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

@ -306,3 +306,45 @@ NS_IMETHODIMP nsTableEncoderSupport::ConvertNoBuffNoErr(
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;
}

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

@ -147,4 +147,42 @@ protected:
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);
};
#endif /* nsUCvJa2Support_h___ */

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

@ -18,16 +18,47 @@
*/
#include "nsUnicodeToEUCJP.h"
#include "nsUCVJA2Dll.h"
//----------------------------------------------------------------------
// Global functions and data [declaration]
// Shift Table
static PRInt16 g0201ShiftTable[] = {
2, uMultibytesCharset,
ShiftCell(u1ByteChar, 1, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x7F),
ShiftCell(u1BytePrefix8EChar, 2, 0x8E, 0x8E, 0x00, 0xA1, 0x00, 0xDF)
};
static PRInt16 g0208ShiftTable[] = {
0, u2BytesGRCharset,
ShiftCell(0,0,0,0,0,0,0,0)
};
static PRInt16 g0212ShiftTable[] = {
0, u2BytesGRPrefix8EA2Charset,
ShiftCell(0,0,0,0,0,0,0,0)
};
static PRInt16 *gShiftTables[4] = {
g0208ShiftTable,
g0201ShiftTable,
g0201ShiftTable,
g0212ShiftTable
};
static PRUint16 *gMappingTables[4] = {
g_0208Mapping,
g_0201Mapping,
g_0201Mapping,
g_0212Mapping
};
//----------------------------------------------------------------------
// Class nsUnicodeToEUCJP [implementation]
nsUnicodeToEUCJP::nsUnicodeToEUCJP()
: nsTableEncoderSupport((uShiftTable*) NULL,
(uMappingTable*) NULL)
: nsTablesEncoderSupport(4,
(uShiftTable**) gShiftTables,
(uMappingTable**) gMappingTables)
{
}
@ -44,7 +75,6 @@ NS_IMETHODIMP nsUnicodeToEUCJP::GetMaxLength(const PRUnichar * aSrc,
PRInt32 aSrcLength,
PRInt32 * aDestLength)
{
// XXX write me
*aDestLength = aSrcLength;
return NS_OK_UENC_EXACTLENGTH;
*aDestLength = 3*aSrcLength;
return NS_OK;
}

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

@ -31,7 +31,7 @@
* @created 17/Feb/1999
* @author Catalin Rotaru [CATA]
*/
class nsUnicodeToEUCJP : public nsTableEncoderSupport
class nsUnicodeToEUCJP : public nsTablesEncoderSupport
{
public: