public GBUnicode(String table_file)throws IOException
{
//BufferedInputStream tables=new BufferedInputStream (new FileInputStream(table_file));
DataInputStream tables=new DataInputStream (new FileInputStream(table_file));
int i,n=0;
byte b,bl,bh,num[]=new byte[20];
UniGB=new Hashtable(7000,1);
while (n<6763 ){
do{
bh=(byte)tables.read();
}while ((char)bh<=' '); //find first non-blank char
bl=(byte)tables.read();
high[n]=bh;
low[n]=bl;
do{
b=(byte)tables.read();
}while (b!=(byte)':'); //find ':'
do{
b=(byte)tables.read();
}while ((char)b<=' '); //find next non-blank char to read as number
i=0;
while ((char)b>='0' && (char)b<='9'){
num[i++]=b;
b=(byte)tables.read();
}
unichar[n]=(char)Integer.parseInt(new String(num,0,0,i));
if (UniGB.get(new Character(unichar[n]))!= null)
System.out.println("Duplicated : "+unichar[n]);
UniGB.put(new Character(unichar[n]),new Integer(n));
n=n+1;
}
tables.close();
}
private int getGBindex(byte high,byte low){
int i,j;
i=high-(byte)0xb0;
j=low-(byte)0xa1;
if (i <39) {// L1 Chinese
if (j<0 || j>94)
return -1;
return (i*94+j);
}
else if (i==39) {//one of the last 89 L1 Chinese
if (j<0 || j>89)
return -1;
return (i*94+j);
}
else {//L2 Chinese
if (j<0 || j>94)
return -1;
return (i*94+j-5);
}
}