//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,
0x62cc,
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.
