add GB18030 4 byte support into the unicode conversion engine.
r=bstell sr=blizzard@mozilla.org
This commit is contained in:
ftang%netscape.com 2006-05-17 02:33:25 +00:00
Родитель 608c67ea72
Коммит 3a43c6e1f0
2 изменённых файлов: 75 добавлений и 2 удалений

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

@ -213,6 +213,16 @@ PRIVATE PRBool uCheckAndGenJohabSymbol(
);
PRIVATE PRBool uCheckAndGen4BytesGB18030(
uShiftTable *shift,
PRInt32* state,
PRUint16 in,
unsigned char* out,
PRUint32 outbuflen,
PRUint32* outlen
);
PRIVATE PRBool uGenComposedHangulCommon(
uShiftTable *shift,
PRInt32* state,
@ -270,7 +280,8 @@ PRIVATE uGeneratorFunc m_generator[uNumOfCharsetType] =
uCnGAlways8BytesComposedHangul,
uCnGAlways8BytesGLComposedHangul,
uCheckAndGenJohabHangul,
uCheckAndGenJohabSymbol
uCheckAndGenJohabSymbol,
uCheckAndGen4BytesGB18030
};
/*=================================================================================
@ -921,3 +932,23 @@ printf("Johab Symbol %x %x in=%x\n", out[0], out[1], in);
return PR_TRUE;
}
}
PRIVATE PRBool uCheckAndGen4BytesGB18030(
uShiftTable *shift,
PRInt32* state,
PRUint16 in,
unsigned char* out,
PRUint32 outbuflen,
PRUint32* outlen
)
{
if(outbuflen < 4)
return PR_FALSE;
out[0] = (in / (10*126*10)) + 0x81;
in %= (10*126*10);
out[1] = (in / (10*126)) + 0x30;
in %= (10*126);
out[2] = (in / (10)) + 0x81;
out[3] = (in % 10) + 0x30;
*outlen = 4;
return PR_TRUE;
}

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

@ -215,6 +215,15 @@ PRIVATE PRBool uCheckAndScanJohabSymbol(
PRUint32* inscanlen
);
PRIVATE PRBool uCheckAndScan4BytesGB18030(
uShiftTable *shift,
PRInt32* state,
unsigned char *in,
PRUint16 *out,
PRUint32 inbuflen,
PRUint32* inscanlen
);
PRIVATE PRBool uScanAlways2Byte(
unsigned char* in,
PRUint16* out
@ -260,8 +269,10 @@ PRIVATE uScannerFunc m_scanner[uNumOfCharsetType] =
uCheckAndScan2ByteGRPrefix8EA7,
uCheckAndScanAlways1ByteShiftGL,
uCnSAlways8BytesComposedHangul,
uCnSAlways8BytesGLComposedHangul,
uCheckAndScanJohabHangul,
uCheckAndScanJohabSymbol
uCheckAndScanJohabSymbol,
uCheckAndScan4BytesGB18030
};
/*=================================================================================
@ -918,3 +929,34 @@ PRIVATE PRBool uCheckAndScanJohabSymbol(
return PR_FALSE;
#endif
}
PRIVATE PRBool uCheckAndScan4BytesGB18030(
uShiftTable *shift,
PRInt32* state,
unsigned char *in,
PRUint16 *out,
PRUint32 inbuflen,
PRUint32* inscanlen
)
{
PRUint32 data;
if(inbuflen < 4)
return PR_FALSE;
if((in[0] < 0x81 ) || (0xfe < in[0]))
return PR_FALSE;
if((in[1] < 0x30 ) || (0x39 < in[1]))
return PR_FALSE;
if((in[2] < 0x81 ) || (0xfe < in[2]))
return PR_FALSE;
if((in[3] < 0x30 ) || (0x39 < in[3]))
return PR_FALSE;
data = (((((in[0] - 0x81) * 10 + (in[1] - 0x30)) * 126) +
(in[2] - 0x81)) * 10 ) + (in[3] - 0x30);
*inscanlen = 4;
if(data >= 0x00010000)
return PR_FALSE;
*out = (PRUint16) data;
return PR_TRUE;
}