adding converter support for x-windows-949 and x-johab
This commit is contained in:
yokoyama%netscape.com 2006-05-17 02:33:30 +00:00
Родитель ad9f228de6
Коммит 099b876d99
2 изменённых файлов: 83 добавлений и 41 удалений

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

@ -176,7 +176,7 @@ PRIVATE PRBool uCheckAndGenAlways1ByteShiftGL(
PRUint32* outlen
);
PRIVATE PRBool uCnGAlways8BytesComposedHangul(
PRIVATE PRBool uCnGAlways8BytesDecomposedHangul(
uShiftTable *shift,
PRInt32* state,
PRUint16 in,
@ -185,7 +185,7 @@ PRIVATE PRBool uCnGAlways8BytesComposedHangul(
PRUint32* outlen
);
PRIVATE PRBool uCnGAlways8BytesGLComposedHangul(
PRIVATE PRBool uCnGAlways6BytesGLDecomposedHangul(
uShiftTable *shift,
PRInt32* state,
PRUint16 in,
@ -223,14 +223,15 @@ PRIVATE PRBool uCheckAndGen4BytesGB18030(
);
PRIVATE PRBool uGenComposedHangulCommon(
PRIVATE PRBool uGenDecomposedHangulCommon(
uShiftTable *shift,
PRInt32* state,
PRUint16 in,
unsigned char* out,
PRUint32 outbuflen,
PRUint32* outlen,
PRUint8 mask
PRUint8 mask,
PRUint16 nbyte
);
PRIVATE PRBool uGenAlways2Byte(
@ -277,11 +278,12 @@ PRIVATE uGeneratorFunc m_generator[uNumOfCharsetType] =
uCheckAndGen2ByteGRPrefix8EA6,
uCheckAndGen2ByteGRPrefix8EA7,
uCheckAndGenAlways1ByteShiftGL,
uCnGAlways8BytesComposedHangul,
uCnGAlways8BytesGLComposedHangul,
uCnGAlways8BytesDecomposedHangul,
uCnGAlways6BytesGLDecomposedHangul,
uCheckAndGenJohabHangul,
uCheckAndGenJohabSymbol,
uCheckAndGen4BytesGB18030
uCheckAndGen4BytesGB18030,
uCheckAndGenAlways2Byte /* place-holder for GR128 */
};
/*=================================================================================
@ -751,14 +753,15 @@ PRIVATE PRBool uCheckAndGenAlways1ByteShiftGL(
/*=================================================================================
=================================================================================*/
PRIVATE PRBool uGenComposedHangulCommon(
PRIVATE PRBool uGenDecomposedHangulCommon(
uShiftTable *shift,
PRInt32* state,
PRUint16 in,
unsigned char* out,
PRUint32 outbuflen,
PRUint32* outlen,
PRUint8 mask
PRUint8 mask,
PRUint16 nbyte
)
{
if(outbuflen < 8)
@ -776,6 +779,7 @@ PRIVATE PRBool uGenComposedHangulCommon(
0xb6, 0xb7, 0xb8, 0xba, 0xbb, 0xbc, 0xbd, 0xbe
};
PRUint16 SIndex, LIndex, VIndex, TIndex;
PRUint16 offset;
/* the following line are copy from Unicode 2.0 page 3-13 */
/* item 1 of Hangul Syllabel Decomposition */
SIndex = in - SBase;
@ -786,16 +790,22 @@ PRIVATE PRBool uGenComposedHangulCommon(
VIndex = (SIndex % NCount) / TCount;
TIndex = SIndex % TCount;
*outlen = 8;
out[0] = out[2] = out[4] = out[6] = (0xa4 & mask);
out[1] = 0xd4 & mask;
out[3] = lMap[LIndex] & mask;
out[5] = (VIndex + 0xbf) & mask;
out[7] = tMap[TIndex] & mask;
*outlen = nbyte;
offset = nbyte == 6 ? 0 : 2;
out[0] = out[2] = out[4] = 0xa4 & mask;
out[1+offset] = lMap[LIndex] & mask;
out[3+offset] = (VIndex + 0xbf) & mask;
out[5+offset] = tMap[TIndex] & mask;
if ( nbyte == 8 )
{
out[6] = 0xa4 & mask;
out[1] = 0xd4 & mask;
}
return PR_TRUE;
}
}
PRIVATE PRBool uCnGAlways8BytesComposedHangul(
PRIVATE PRBool uCnGAlways8BytesDecomposedHangul(
uShiftTable *shift,
PRInt32* state,
PRUint16 in,
@ -804,9 +814,14 @@ PRIVATE PRBool uCnGAlways8BytesComposedHangul(
PRUint32* outlen
)
{
return uGenComposedHangulCommon(shift,state,in,out,outbuflen,outlen,0xff);
return uGenDecomposedHangulCommon(shift,state,in,out,outbuflen,outlen,0xff,8);
}
PRIVATE PRBool uCnGAlways8BytesGLComposedHangul(
/*
For rendering of Hangul in X11 with fonts with glyphs for only
2350 syllables, drop the first 2bytes anchoring the representation
of Hangul syllables with 8byte sequence.
*/
PRIVATE PRBool uCnGAlways6BytesGLDecomposedHangul(
uShiftTable *shift,
PRInt32* state,
PRUint16 in,
@ -815,7 +830,7 @@ PRIVATE PRBool uCnGAlways8BytesGLComposedHangul(
PRUint32* outlen
)
{
return uGenComposedHangulCommon(shift,state,in,out,outbuflen,outlen,0x7f);
return uGenDecomposedHangulCommon(shift,state,in,out,outbuflen,outlen,0x7f,6);
}
PRIVATE PRBool uCheckAndGenJohabHangul(
uShiftTable *shift,

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

@ -74,6 +74,14 @@ PRIVATE PRBool uCheckAndScanAlways2ByteShiftGR(
PRUint32 inbuflen,
PRUint32* inscanlen
);
PRIVATE PRBool uCheckAndScanAlways2ByteGR128(
uShiftTable *shift,
PRInt32* state,
unsigned char *in,
PRUint16 *out,
PRUint32 inbuflen,
PRUint32* inscanlen
);
PRIVATE PRBool uCheckAndScanByTable(
uShiftTable *shift,
PRInt32* state,
@ -171,7 +179,8 @@ PRIVATE PRBool uCheckAndScanAlways1ByteShiftGL(
PRUint32 inbuflen,
PRUint32* inscanlen
);
PRIVATE PRBool uCnSAlways8BytesComposedHangul(
PRIVATE PRBool uCnSAlways8BytesDecomposedHangul(
uShiftTable *shift,
PRInt32* state,
unsigned char *in,
@ -179,8 +188,7 @@ PRIVATE PRBool uCnSAlways8BytesComposedHangul(
PRUint32 inbuflen,
PRUint32* inscanlen
);
PRIVATE PRBool uCnSAlways8BytesGLComposedHangul(
PRIVATE PRBool uCnSAlways8BytesGLDecomposedHangul(
uShiftTable *shift,
PRInt32* state,
unsigned char *in,
@ -189,7 +197,7 @@ PRIVATE PRBool uCnSAlways8BytesGLComposedHangul(
PRUint32* inscanlen
);
PRIVATE PRBool uScanComposedHangulCommon(
PRIVATE PRBool uScanDecomposedHangulCommon(
uShiftTable *shift,
PRInt32* state,
unsigned char *in,
@ -268,11 +276,12 @@ PRIVATE uScannerFunc m_scanner[uNumOfCharsetType] =
uCheckAndScan2ByteGRPrefix8EA6,
uCheckAndScan2ByteGRPrefix8EA7,
uCheckAndScanAlways1ByteShiftGL,
uCnSAlways8BytesComposedHangul,
uCnSAlways8BytesGLComposedHangul,
uCnSAlways8BytesDecomposedHangul,
uCnSAlways8BytesGLDecomposedHangul,
uCheckAndScanJohabHangul,
uCheckAndScanJohabSymbol,
uCheckAndScan4BytesGB18030
uCheckAndScan4BytesGB18030,
uCheckAndScanAlways2ByteGR128
};
/*=================================================================================
@ -439,6 +448,32 @@ PRIVATE PRBool uCheckAndScanAlways2ByteShiftGR(
}
/*=================================================================================
=================================================================================*/
PRIVATE PRBool uCheckAndScanAlways2ByteGR128(
uShiftTable *shift,
PRInt32* state,
unsigned char *in,
PRUint16 *out,
PRUint32 inbuflen,
PRUint32* inscanlen
)
{
/*
* The first byte should be in [0xa1,0xfe]
* and the second byte can take any value with MSB = 1.
* Used by CP949 -> Unicode converter.
*/
if(inbuflen < 2 || ! CHK_GR94(in[0]) || ! in[1] & 0x80 )
return PR_FALSE;
else
{
*inscanlen = 2;
*out = (in[0] << 8) | in[1];
return PR_TRUE;
}
}
/*=================================================================================
=================================================================================*/
PRIVATE PRBool uCheckAndScanByTable(
uShiftTable *shift,
@ -713,7 +748,7 @@ PRIVATE PRBool uCheckAndScanAlways1ByteShiftGL(
#define VCount 21
#define TCount 28
#define NCount (VCount * TCount)
PRIVATE PRBool uScanComposedHangulCommon(
PRIVATE PRBool uScanDecomposedHangulCommon(
uShiftTable *shift,
PRInt32* state,
unsigned char *in,
@ -792,7 +827,7 @@ PRIVATE PRBool uScanComposedHangulCommon(
/*=================================================================================
=================================================================================*/
PRIVATE PRBool uCnSAlways8BytesComposedHangul(
PRIVATE PRBool uCnSAlways8BytesDecomposedHangul(
uShiftTable *shift,
PRInt32* state,
unsigned char *in,
@ -801,12 +836,12 @@ PRIVATE PRBool uCnSAlways8BytesComposedHangul(
PRUint32* inscanlen
)
{
return uScanComposedHangulCommon(shift,state,in,out,inbuflen,inscanlen,0xff);
return uScanDecomposedHangulCommon(shift,state,in,out,inbuflen,inscanlen,0xff);
}
/*=================================================================================
=================================================================================*/
PRIVATE PRBool uCnSAlways8BytesGLComposedHangul(
PRIVATE PRBool uCnSAlways8BytesGLDecomposedHangul(
uShiftTable *shift,
PRInt32* state,
unsigned char *in,
@ -815,7 +850,7 @@ PRIVATE PRBool uCnSAlways8BytesGLComposedHangul(
PRUint32* inscanlen
)
{
return uScanComposedHangulCommon(shift,state,in,out,inbuflen,inscanlen,0x7f);
return uScanDecomposedHangulCommon(shift,state,in,out,inbuflen,inscanlen,0x7f);
}
PRIVATE PRBool uCheckAndScanJohabHangul(
uShiftTable *shift,
@ -828,7 +863,6 @@ PRIVATE PRBool uCheckAndScanJohabHangul(
{
/* since we don't have code to convert Johab to Unicode right now *
* make this part of code #if 0 to save space untill we fully test it */
#if 0
if(inbuflen < 2)
return PR_FALSE;
else {
@ -867,11 +901,9 @@ PRIVATE PRBool uCheckAndScanJohabHangul(
return PR_FALSE;
/* the following line is from Unicode 2.0 page 3-13 item 5 */
*out = ( LIndex * VCount + VIndex) * TCount + TIndex + SBase;
*inscanlen = 2;
return PR_TRUE;
}
#else
return PR_FALSE;
#endif
}
PRIVATE PRBool uCheckAndScanJohabSymbol(
uShiftTable *shift,
@ -882,9 +914,6 @@ PRIVATE PRBool uCheckAndScanJohabSymbol(
PRUint32* inscanlen
)
{
/* since we don't have code to convert Johab to Unicode right now
* make this part of code #if 0 to save space untill we fully test it */
#if 0
if(inbuflen < 2)
return PR_FALSE;
else {
@ -928,11 +957,9 @@ PRIVATE PRBool uCheckAndScanJohabSymbol(
(lo < 161 ? 1 : 0) + offset) + d8_off) << 8 ) |
(lo - ((lo < 161) ? ((lo > 126) ? 34 : 16) :
128));
*inscanlen = 2;
return PR_TRUE;
}
#else
return PR_FALSE;
#endif
}
PRIVATE PRBool uCheckAndScan4BytesGB18030(
uShiftTable *shift,