java 实现 简体gb 到 繁体 再到 big5码 的转换

来源:百度知道 编辑:UC知道 时间:2024/06/24 13:58:42
网上看到一些代码 正在努力研究 但是本人才疏学浅 不明白怎样写一个main类 使之可运行

QQ 116970539 欢迎加我或者邮件我 分是绝对不会少的 在下十分希望高手给予教导 助我弄懂此问题...呵呵...

先谢过

不会写main 怎么会问这个问题呢

public class CharDecode {

public static void main(String[] args) throws Exception{
// TODO: Add your code here
System.setProperty("file.encoding","big5");//系统默认字符改成big5

System.out.println("please enter a chinese String:");
byte [] buf = new byte[1024];
String strInfo = null;
int pos = 0;
int ch = 0;
while(true)
{
ch = System.in.read();
System.out.println(Integer.toHexString(ch));
switch(ch)
{
case '\r':
break;
case '\n':
strInfo = new String(buf,0,pos);//使用默认字符集
for(int i=0;i<strInfo.length();i++)
{
System.out.println(Integer.toHexString(/*(int)*/strInfo.charAt(i)));
}
System.out.println(new String(strInfo.getBytes("big5"),"gb2312"));//big5转换成gb2312
break;
default: