зеркало из https://github.com/mozilla/gecko-dev.git
Multi table support added.
This commit is contained in:
Родитель
8cb4f1a4b6
Коммит
d0c8035a37
|
@ -56,6 +56,13 @@ public:
|
|||
NS_IMETHOD ConvertByTable(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable) = 0;
|
||||
|
||||
/**
|
||||
* Converts data using a set of lookup tables.
|
||||
*/
|
||||
NS_IMETHOD ConvertByTables(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable, uMappingTable ** aMappingTable) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -55,6 +55,10 @@ public:
|
|||
NS_IMETHOD ConvertByTable(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable);
|
||||
|
||||
NS_IMETHOD ConvertByTables(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable, uMappingTable ** aMappingTable);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -114,6 +118,49 @@ NS_IMETHODIMP nsUnicodeEncodeHelper::ConvertByTable(const PRUnichar * aSrc,
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeEncodeHelper::ConvertByTables(const PRUnichar * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
char * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable)
|
||||
{
|
||||
const PRUnichar * src = aSrc;
|
||||
const PRUnichar * srcEnd = aSrc + *aSrcLength;
|
||||
char * dest = aDest;
|
||||
PRInt32 destLen = *aDestLength;
|
||||
|
||||
PRUnichar med;
|
||||
PRInt32 bcw; // byte count for write;
|
||||
nsresult res = NS_OK;
|
||||
PRInt32 i;
|
||||
|
||||
while (src < srcEnd) {
|
||||
for (i=0; i<aTableCount; i++)
|
||||
if (uMapCode((uTable*) aMappingTable[i], *src, &med)) break;
|
||||
|
||||
src++;
|
||||
if (i == aTableCount) {
|
||||
res = NS_ERROR_UENC_NOMAPPING;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!uGenerate(aShiftTable[i], 0, med, (PRUint8 *)dest, destLen,
|
||||
(PRUint32 *)&bcw)) {
|
||||
src--;
|
||||
res = NS_OK_UENC_MOREOUTPUT;
|
||||
break;
|
||||
}
|
||||
|
||||
dest += bcw;
|
||||
destLen -= bcw;
|
||||
}
|
||||
|
||||
*aSrcLength = src - aSrc;
|
||||
*aDestLength = dest - aDest;
|
||||
return res;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsEncodeHelperFactory [implementation]
|
||||
|
|
|
@ -27,8 +27,9 @@
|
|||
mDecArray[4].mCID = &kISO2022JPToUnicodeCID;
|
||||
mDecArray[5].mCID = &kEUCJPToUnicodeCID;
|
||||
|
||||
mEncSize = 2;
|
||||
mEncSize = 3;
|
||||
mEncArray = new ConverterInfo [mEncSize];
|
||||
|
||||
mEncArray[0].mCID = &kUnicodeToLatin1CID;
|
||||
mEncArray[1].mCID = &kUnicodeToSJISCID;
|
||||
mEncArray[2].mCID = &kUnicodeToEUCJPCID;
|
||||
|
|
|
@ -55,6 +55,10 @@ public:
|
|||
NS_IMETHOD ConvertByTable(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable);
|
||||
|
||||
NS_IMETHOD ConvertByTables(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable, uMappingTable ** aMappingTable);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -114,6 +118,49 @@ NS_IMETHODIMP nsUnicodeEncodeHelper::ConvertByTable(const PRUnichar * aSrc,
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeEncodeHelper::ConvertByTables(const PRUnichar * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
char * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable)
|
||||
{
|
||||
const PRUnichar * src = aSrc;
|
||||
const PRUnichar * srcEnd = aSrc + *aSrcLength;
|
||||
char * dest = aDest;
|
||||
PRInt32 destLen = *aDestLength;
|
||||
|
||||
PRUnichar med;
|
||||
PRInt32 bcw; // byte count for write;
|
||||
nsresult res = NS_OK;
|
||||
PRInt32 i;
|
||||
|
||||
while (src < srcEnd) {
|
||||
for (i=0; i<aTableCount; i++)
|
||||
if (uMapCode((uTable*) aMappingTable[i], *src, &med)) break;
|
||||
|
||||
src++;
|
||||
if (i == aTableCount) {
|
||||
res = NS_ERROR_UENC_NOMAPPING;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!uGenerate(aShiftTable[i], 0, med, (PRUint8 *)dest, destLen,
|
||||
(PRUint32 *)&bcw)) {
|
||||
src--;
|
||||
res = NS_OK_UENC_MOREOUTPUT;
|
||||
break;
|
||||
}
|
||||
|
||||
dest += bcw;
|
||||
destLen -= bcw;
|
||||
}
|
||||
|
||||
*aSrcLength = src - aSrc;
|
||||
*aDestLength = dest - aDest;
|
||||
return res;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsEncodeHelperFactory [implementation]
|
||||
|
|
Загрузка…
Ссылка в новой задаче