返回列表 發帖
本帖最後由 t3742238 於 2013-7-20 17:26 編輯
  1. import java.io.UnsupportedEncodingException;
  2. public class tqc209
  3. {
  4.   public static void main(String args[])   throws UnsupportedEncodingException
  5.   {
  6.          String str="JAVA程式";
  7.          String toHex=toHex(str);
  8.          System.out.println("Unicode碼 "+toHex);
  9.          String toBig5=new String(str.getByts("Big5"),"ISO8859-1");
  10.          String inHex=toHex(toBig5);
  11.          System.out.println("Big5 碼 16進位 \t\t"+inHex);
  12.          String to str=new String(toBig5.getByts("ISO8859-1"),"Big5");
  13.          System.out.println("原字串\t\t\t"+toSter);
  14.   }
  15.   public static String toHex(String str)
  16.   {
  17.     String res=" ";
  18.     char tmp;
  19.     for(int i=0; i<str.length();i++)
  20.     {
  21.       tem=str.charAt(i);
  22.       String+"0000"+Integer.toHexString(tmp);
  23.       rest+=substring(t.length()-4)+" ";
  24.     }
  25.     return res;
  26.   }

  27. }
複製代碼

TOP

返回列表