本文目錄一覽:
java 實現 簡體gb 到 繁體 再到 big5碼 的轉換
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;istrInfo.length();i++)
{
System.out.println(Integer.toHexString(/*(int)*/strInfo.charAt(i)));
}
System.out.println(new String(strInfo.getBytes(“big5″),”gb2312”));//big5轉換成gb2312
break;
default:
buf[pos++] = (byte)ch;
}
}
}
}
如何用java將繁體字轉為簡體字
我不知道你是要自己實現,還是說只要有個類庫就可以了,下面是我找的一個類庫的實例代碼:
package test3;
import net.sf.chineseutils.ChineseUtils;
public class Test {
public static void main(String args[]) throws Exception{
System.out.println(ChineseUtils.simpToTrad(“把BIG5繁體字符串轉換成的GB簡體字符串。”));
}
}
輸出:
把BIG5繁體字符串轉換成的GB簡體字符串。
java如何做到繁體中文轉換
說的不具體,如果是在JSP網頁上,可以使用資源文件,properties擴展名
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/195874.html