189 static const unsigned short b1c4[][2] = {
197 static const unsigned short b2c3[][2] = {
208 (
const codes_t *array,
int high,
unsigned short code)
218 for (; low <= high; mid = (low + high) >> 1)
220 if ((array[mid].code <= code) && (array[mid + 1].
code > code))
222 if (0 == array[mid].peer)
227 tmp = ((code & 0xff00) - (array[mid].code & 0xff00)) >> 8;
228 high = code & 0x00ff;
229 low = array[mid].
code & 0x00ff;
240 distance = tmp * 0x9d + high - low +
241 (high >= 0xa1 ? (low >= 0xa1 ? 0 : -0x22)
242 : (low >= 0xa1 ? +0x22 : 0));
252 tmp = (array[mid].
peer & 0x00ff) + distance - 0x21;
253 tmp = (array[mid].
peer & 0xff00) + ((tmp / 0x5e) << 8)
260 tmp = ((code & 0xff00) - (array[mid].code & 0xff00)) >> 8;
266 distance = tmp * 0x5e
267 + ((int) (code & 0x00ff) - (int) (array[mid].code & 0x00ff));
273 low = array[mid].
peer & 0x00ff;
274 tmp = low + distance - (low >= 0xa1 ? 0x62 : 0x40);
276 tmp = (array[mid].
peer & 0xff00) + ((tmp / 0x9d) << 8)
277 + (low > 0x3e ? 0x62 : 0x40) + low;
281 else if (array[mid].code > code)
294 unsigned short cns = 0;
301 for (
i = 0;
i <
sizeof(
b1c4) / (
sizeof(
unsigned short) * 2);
i++)
303 if (
b1c4[
i][0] == big5)
306 return (
b1c4[
i][1] | 0x8080U);
313 else if (big5 == 0xc94aU)
322 for (
i = 0;
i <
sizeof(
b2c3) / (
sizeof(
unsigned short) * 2);
i++)
324 if (
b2c3[
i][0] == big5)
327 return (
b2c3[
i][1] | 0x8080U);
338 return (
unsigned short)
'?';
348 unsigned int big5 = 0;
361 for (
i = 0;
i <
sizeof(
b2c3) / (
sizeof(
unsigned short) * 2);
i++)
363 if (
b2c3[
i][1] == cns)
368 for (
i = 0;
i <
sizeof(
b1c4) / (
sizeof(
unsigned short) * 2);
i++)
370 if (
b1c4[
i][1] == cns)
static const codes_t big5Level1ToCnsPlane1[25]
static const codes_t big5Level2ToCnsPlane2[48]
static unsigned short BinarySearchRange(const codes_t *array, int high, unsigned short code)
unsigned short CNStoBIG5(unsigned short cns, unsigned char lc)
static const unsigned short b2c3[][2]
static const codes_t cnsPlane2ToBig5Level2[49]
unsigned short BIG5toCNS(unsigned short big5, unsigned char *lc)
static const codes_t cnsPlane1ToBig5Level1[26]
static const unsigned short b1c4[][2]