- /**
- * 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<s.length(); i++){
- int ch=(int)s.charAt(i);
- String s4="0000"+Integer.toHexString(ch);
- str=str+s4.substring(s4.length()-4)+" ";
- }
- return str;
- }
- }
Big5字与Unicode的互换
最新推荐文章于 2021-02-20 23:00:09 发布
本文提供了一个Java实用工具类,用于实现Big5编码与Unicode编码之间的相互转换,并附带了一个将字符串转换为十六进制表示的方法。这些功能对于处理不同编码格式的中文字符特别有用。
536

被折叠的 条评论
为什么被折叠?



