模拟试题

3773考试网计算机等级考试模拟试题正文

2011计算机二级JAVA编程:Big5字与Unicode的互换

来源:fjzsksw.com 2010-11-4 14:17:18

 

 

 Big5字与Unicode的互换

  /**

  * Big5字与Unicode的互换

  * 转换后的正常字型

  */

  import java.io.*;

  public class MyUtil{

  public static String big5ToUnicode(String s){

  try{

  return new String(s.getBytes("ISO8859_1"), "Big5");

  }

  catch (UnsupportedEncodingException uee){

  return s;

  }

  }

  public static String UnicodeTobig5(String s){

  try{

  return new String(s.getBytes("Big5"), "ISO8859_1");

  }

  catch (UnsupportedEncodingException uee){

  return s;

  }

  }

  public static String toHexString(String s){

  String str="";

  for (int i=0; i

  int ch=(int)s.charAt(i);

  String s4="0000"+Integer.toHexString(ch);

  str=str+s4.substring(s4.length()-4)+" ";

  }

  return str;

  }

  }

 

 

触屏版 电脑版
3773考试网 琼ICP备12003406号-1