当前位置: 编程技术>java/j2ee
java big5到gb2312的编码转换
来源: 互联网 发布时间:2014-10-17
本文导语: package com.Big5ToUTF8; import java.io.*; public class Big5Tran { private static final String tabFile ="bg-gb.tab"; private static byte[] data; static{ try{ FileInputStream fis =new FileInputStream(tabFile); int len =fis.available(); data =new byte[len]; fis.read(data); fis.close(); }catch(Except...
package com.Big5ToUTF8;
import java.io.*;
public class Big5Tran {
private static final String tabFile ="bg-gb.tab";
private static byte[] data;
static{
try{
FileInputStream fis =new FileInputStream(tabFile);
int len =fis.available();
data =new byte[len];
fis.read(data);
fis.close();
}catch(Exception ex){
ex.printStackTrace();
System.exit(1);
}
}
/**
*取得BIG5汉字big在data中的偏移
*/
private static int indexOf(int big){
int high =(big>>>8)&0xff;
int low =big&0xff;
high -= 0xa1;
if(low0x7e&&low
import java.io.*;
public class Big5Tran {
private static final String tabFile ="bg-gb.tab";
private static byte[] data;
static{
try{
FileInputStream fis =new FileInputStream(tabFile);
int len =fis.available();
data =new byte[len];
fis.read(data);
fis.close();
}catch(Exception ex){
ex.printStackTrace();
System.exit(1);
}
}
/**
*取得BIG5汉字big在data中的偏移
*/
private static int indexOf(int big){
int high =(big>>>8)&0xff;
int low =big&0xff;
high -= 0xa1;
if(low0x7e&&low