зеркало из https://github.com/mozilla/gecko-dev.git
fix 79273
add GB18030 4 byte support into the unicode conversion engine. r=bstell sr=blizzard@mozilla.org
This commit is contained in:
Родитель
dd3c361895
Коммит
8ab765e049
|
@ -56,6 +56,7 @@ typedef enum {
|
|||
uComposedHangulGLCharset,
|
||||
uJohabHangulCharset,
|
||||
uJohabSymbolCharset,
|
||||
u4BytesGB18030Charset,
|
||||
uNumOfCharsetType
|
||||
} uScanClassID;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче