来自Moto得GB2Unicode类
发表于:2007-07-04来源:作者:点击数:
标签:
//package com.mot.j2me.midlets.dictionary; public class GB2Uni { private static final byteGB_PAGE_SIZE =94; char gGBToUniTbl[] = { 0x554A, 0x963F, 0x57C3, 0x6328, 0x54CE, 0x5509, 0x54C0, 0x7691, 0x764C, 0x853C, 0x77EE, 0x827E, 0x788D, 0x723
//package com.mot.j2me.midlets.dictionary;
public class GB2Uni
{
private static final byte GB_PAGE_SIZE = 94;
char gGBToUniTbl[] = {
0x554A,
0x963F,
0x57C3,
0x6328,
0x54CE,
0x5509,
0x54C0,
0x7691,
0x764C,
0x853C,
0x77EE,
0x827E,
0x788D,
0x7231,
0x9698,
0x978D,
0x6C28,
0x5B89,
0x4FFA,
0x6309,
0x6697,
0x5CB8,
0x80FA,
0x6848,
0x80AE,
0x6602,
0x76CE,
0x51F9,
0x6556,
0x71AC,
0x7FF1,
0x8884,
0x50B2,
0x5965,
0x61CA,
0x6FB3,
0x82AD,
0x634C,
0x6252,
0x53ED,
0x5427,
0x7B06,
0x516B,
0x75A4,
0x5DF4,
0x62D4,
0x8DCB,
0x9776,
0x628A,
0x8019,
0x575D,
0x9738,
0x7F62,
0x7238,
0x767D,
0x67CF,
0x767E,
0x6446,
0x4F70,
0x8D25,
0x62DC,
0x7A17,
0x6591,
0x73ED,
0x642C,
0x6273,
0x822C,
0x9881,
0x677F,
0x7248,
0x626E,
0x62
CC,
0x4F34,
0x74E3,
0x534A,
0x529E,
0x7ECA,
0x90A6,
0x5E2E,
0x6886,
0x699C,
0x8180,
0x7ED1,
0x68D2,
0x78C5,
0x868C,
0x9551,
0x508D,
0x8C24,
0x82DE,
0x80DE,
0x5305,
0x8912,
0x5265,
0x8584,
0x96F9,
0x4FDD,
0x5821,
0x9971,
0x5B9D,
0x62B1,
0x62A5,
0x66B4,
0x8C79,
0x9C8D,
0x7206,
0x676F,
0x7891,
0x60B2,
0x5351,
0x5317,
0x8F88,
0x80CC,
0x8D1D,
0x94A1,
0x500D,
0x72C8,
0x5907,
0x60EB,
};
char HIGH_BYTE(char code)
{
return (char)((code) & 0xFF00);
}
char LOW_BYTE(char code)
{
return (char)((code) & 0x00FF);
}
public char converter(char code)
{
short index;
short pageNum;
// validate the input code
if (!((HIGH_BYTE(code) >= 0xB000) &&
(HIGH_BYTE(code) <= 0xF700) &&
(LOW_BYTE(code) >= 0x00A1) && //0xD5E2
(LOW_BYTE(code) <= 0x00FE)))
return 0x20; // invalid code
// valid GB code in CJK range
pageNum = (short)(((HIGH_BYTE(code) - 0xB000) >> 8));
index = (short)(pageNum*94 + (LOW_BYTE(code) - 0x00A1));
if (HIGH_BYTE(code) > 0xD700) // special Chinese characters
index -= 5;
return gGBToUniTbl[index];
}
}//class defined end.
原文转自:http://www.ltesting.net