本帖最後由 t3742238 於 2013-7-20 17:26 編輯
- import java.io.UnsupportedEncodingException;
- public class tqc209
- {
- public static void main(String args[]) throws UnsupportedEncodingException
- {
- String str="JAVA程式";
- String toHex=toHex(str);
- System.out.println("Unicode碼 "+toHex);
- String toBig5=new String(str.getByts("Big5"),"ISO8859-1");
- String inHex=toHex(toBig5);
- System.out.println("Big5 碼 16進位 \t\t"+inHex);
- String to str=new String(toBig5.getByts("ISO8859-1"),"Big5");
- System.out.println("原字串\t\t\t"+toSter);
- }
- public static String toHex(String str)
- {
- String res=" ";
- char tmp;
- for(int i=0; i<str.length();i++)
- {
- tem=str.charAt(i);
- String+"0000"+Integer.toHexString(tmp);
- rest+=substring(t.length()-4)+" ";
- }
- return res;
- }
- }
複製代碼 |