|
|
|
|
| 78 |
public: |
78 |
public: |
| 79 |
nsUnicodeToGB18030Uniq2Bytes() |
79 |
nsUnicodeToGB18030Uniq2Bytes() |
| 80 |
: nsTableEncoderSupport((uShiftTable*) &g_2BytesShiftTable, |
80 |
: nsTableEncoderSupport((uShiftTable*) &g_2BytesShiftTable, |
| 81 |
(uMappingTable*) &g_uf_gb18030_2bytes) {}; |
81 |
(uMappingTable*) &g_uf_gb18030_2bytes, 2) {}; |
| 82 |
protected: |
82 |
protected: |
| 83 |
NS_IMETHOD GetMaxLength(const PRUnichar * aSrc, |
|
|
| 84 |
PRInt32 aSrcLength, |
| 85 |
PRInt32 * aDestLength) |
| 86 |
{ |
| 87 |
*aDestLength = 2 * aSrcLength; |
| 88 |
return NS_OK; |
| 89 |
}; |
| 90 |
}; |
83 |
}; |
| 91 |
//----------------------------------------------------------------------- |
84 |
//----------------------------------------------------------------------- |
| 92 |
// Private class used by nsUnicodeToGB18030 |
85 |
// Private class used by nsUnicodeToGB18030 |
|
|
| 100 |
public: |
93 |
public: |
| 101 |
nsUnicodeTo4BytesGB18030() |
94 |
nsUnicodeTo4BytesGB18030() |
| 102 |
: nsTableEncoderSupport( (uShiftTable*) &g_4BytesGB18030ShiftTable, |
95 |
: nsTableEncoderSupport( (uShiftTable*) &g_4BytesGB18030ShiftTable, |
| 103 |
(uMappingTable*) &g_uf_gb18030_4bytes) {}; |
96 |
(uMappingTable*) &g_uf_gb18030_4bytes, 4) {}; |
| 104 |
protected: |
97 |
protected: |
| 105 |
NS_IMETHOD GetMaxLength(const PRUnichar * aSrc, |
|
|
| 106 |
PRInt32 aSrcLength, |
| 107 |
PRInt32 * aDestLength) |
| 108 |
{ |
| 109 |
*aDestLength = 4 * aSrcLength; |
| 110 |
return NS_OK_UDEC_EXACTLENGTH; |
| 111 |
}; |
| 112 |
}; |
98 |
}; |
| 113 |
//----------------------------------------------------------------------- |
99 |
//----------------------------------------------------------------------- |
| 114 |
// Private class used by nsUnicodeToGBK |
100 |
// Private class used by nsUnicodeToGBK |
|
|
| 122 |
public: |
108 |
public: |
| 123 |
nsUnicodeToGBKUniq2Bytes() |
109 |
nsUnicodeToGBKUniq2Bytes() |
| 124 |
: nsTableEncoderSupport( (uShiftTable*) &g_2BytesShiftTable, |
110 |
: nsTableEncoderSupport( (uShiftTable*) &g_2BytesShiftTable, |
| 125 |
(uMappingTable*) &g_uf_gbk_2bytes) {}; |
111 |
(uMappingTable*) &g_uf_gbk_2bytes, 2) {}; |
| 126 |
protected: |
112 |
protected: |
| 127 |
NS_IMETHOD GetMaxLength(const PRUnichar * aSrc, |
|
|
| 128 |
PRInt32 aSrcLength, |
| 129 |
PRInt32 * aDestLength) |
| 130 |
{ |
| 131 |
*aDestLength = 2 * aSrcLength; |
| 132 |
return NS_OK_UDEC_EXACTLENGTH; |
| 133 |
}; |
| 134 |
}; |
113 |
}; |
| 135 |
//----------------------------------------------------------------------- |
114 |
//----------------------------------------------------------------------- |
| 136 |
// nsUnicodeToGB18030 |
115 |
// nsUnicodeToGB18030 |
|
|
| 143 |
{ |
122 |
{ |
| 144 |
m4BytesEncoder = new nsUnicodeTo4BytesGB18030(); |
123 |
m4BytesEncoder = new nsUnicodeTo4BytesGB18030(); |
| 145 |
} |
124 |
} |
| 146 |
NS_IMETHODIMP nsUnicodeToGB18030::GetMaxLength(const PRUnichar * aSrc, |
125 |
|
| 147 |
PRInt32 aSrcLength, |
|
|
| 148 |
PRInt32 * aDestLength) |
| 149 |
{ |
| 150 |
*aDestLength = 4 * aSrcLength; |
| 151 |
return NS_OK; |
| 152 |
} |
| 153 |
PRBool nsUnicodeToGB18030::EncodeSurrogate( |
126 |
PRBool nsUnicodeToGB18030::EncodeSurrogate( |
| 154 |
PRUnichar aSurrogateHigh, |
127 |
PRUnichar aSurrogateHigh, |
| 155 |
PRUnichar aSurrogateLow, |
128 |
PRUnichar aSurrogateLow, |
|
|
| 205 |
//----------------------------------------------------------------------- |
178 |
//----------------------------------------------------------------------- |
| 206 |
nsUnicodeToGB18030Font1::nsUnicodeToGB18030Font1() |
179 |
nsUnicodeToGB18030Font1::nsUnicodeToGB18030Font1() |
| 207 |
: nsTableEncoderSupport( (uShiftTable*) &g_2BytesShiftTable, |
180 |
: nsTableEncoderSupport( (uShiftTable*) &g_2BytesShiftTable, |
| 208 |
(uMappingTable*) &g_uf_gb18030_4bytes) |
181 |
(uMappingTable*) &g_uf_gb18030_4bytes, 4) |
| 209 |
{ |
182 |
{ |
| 210 |
|
183 |
|
| 211 |
} |
184 |
} |
| 212 |
|
185 |
|
| 213 |
NS_IMETHODIMP nsUnicodeToGB18030Font1::GetMaxLength(const PRUnichar * aSrc, |
|
|
| 214 |
PRInt32 aSrcLength, |
| 215 |
PRInt32 * aDestLength) |
| 216 |
{ |
| 217 |
*aDestLength = 4 * aSrcLength; |
| 218 |
return NS_OK_UDEC_EXACTLENGTH; // font encoding is exactly 4 bytes |
| 219 |
} |
| 220 |
|
| 221 |
NS_IMETHODIMP nsUnicodeToGB18030Font1::FillInfo(PRUint32 *aInfo) |
186 |
NS_IMETHODIMP nsUnicodeToGB18030Font1::FillInfo(PRUint32 *aInfo) |
| 222 |
{ |
187 |
{ |
| 223 |
nsresult res = nsTableEncoderSupport::FillInfo(aInfo); |
188 |
nsresult res = nsTableEncoderSupport::FillInfo(aInfo); |
|
|
| 357 |
//---------------------------------------------------------------------- |
322 |
//---------------------------------------------------------------------- |
| 358 |
// Class nsUnicodeToGBK [implementation] |
323 |
// Class nsUnicodeToGBK [implementation] |
| 359 |
|
324 |
|
| 360 |
nsUnicodeToGBK::nsUnicodeToGBK() |
325 |
nsUnicodeToGBK::nsUnicodeToGBK(PRUint32 aMaxLength) : |
|
|
326 |
nsEncoderSupport(aMaxLength) |
| 361 |
{ |
327 |
{ |
| 362 |
mExtensionEncoder = nsnull; |
328 |
mExtensionEncoder = nsnull; |
| 363 |
m4BytesEncoder = nsnull; |
329 |
m4BytesEncoder = nsnull; |
|
|
| 561 |
|
527 |
|
| 562 |
//---------------------------------------------------------------------- |
528 |
//---------------------------------------------------------------------- |
| 563 |
// Subclassing of nsTableEncoderSupport class [implementation] |
529 |
// Subclassing of nsTableEncoderSupport class [implementation] |
| 564 |
|
|
|
| 565 |
NS_IMETHODIMP nsUnicodeToGBK::GetMaxLength(const PRUnichar * aSrc, |
| 566 |
PRInt32 aSrcLength, |
| 567 |
PRInt32 * aDestLength) |
| 568 |
{ |
| 569 |
*aDestLength = 2 * aSrcLength; |
| 570 |
return NS_OK; |
| 571 |
} |
| 572 |
|
| 573 |
|
530 |
|
| 574 |
NS_IMETHODIMP nsUnicodeToGBK::FillInfo(PRUint32 *aInfo) |
531 |
NS_IMETHODIMP nsUnicodeToGBK::FillInfo(PRUint32 *aInfo) |
| 575 |
{ |
532 |
{ |