首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

字符集的互相转换

2012-07-01 
字符集的相互转换public class Util { /*** 字符集转换ISO_GBK* @param tmp* @return*/ public static Str

字符集的相互转换

public class Util {
/**
* 字符集转换ISO_GBK
* @param tmp
* @return
*/
public static String swithCharISO_GBK(String tmp){
String str=null;
try {
str = new String(tmp.getBytes("iso-8859-1"),"GBK");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return str;
}

/**
* 字符集转换GBK_ISO
* @param tmp
* @return
*/
public static String swithCharGBK_ISO(String tmp){
String str=null;
try {
str = new String(tmp.getBytes("GBK"),"iso-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return str;
}


}

热点排行