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

java 汉语转码demo大全

2013-03-26 
java 中文转码demo大全public static void main(String[] argv){?try {???????????????? System.out.print

java 中文转码demo大全

public static void main(String[] argv){?
try {?
?????
?????????? System.out.println("中文");//1?
?
?????????? System.out.println("中文".getBytes());//2?
?
?????????? System.out.println("中文".getBytes("GB2312"));//3?
?
?????????? System.out.println("中文".getBytes("ISO8859_1"));//4?
????????????
?
?????????? System.out.println(new String("中文".getBytes()));//5?
?
?????????? System.out.println(new String("中文".getBytes(),"GB2312"));//6?
?
?????????? System.out.println(new String("中文".getBytes(),"ISO8859_1"));//7?
?
?????????? System.out.println(new String("中文".getBytes("GB2312")));//8?
?
?????????? System.out.println(new String("中文".getBytes("GB2312"),"GB2312"));//9?
????????????
?
?????????? System.out.println(new String("中文".getBytes("GB2312"),"ISO8859_1"));//10?
?
?????????? System.out.println(new String("中文".getBytes("ISO8859_1")));//11?
?
?????????? System.out.println(new String("中文".getBytes("ISO8859_1"),"utf-8"));//12?
?
?????????? System.out.println(new String("中文发送短信".getBytes("ISO8859_1"),"utf-8"));//13?
????????????
?????????? //编码与解码?
?????????? String cont=URLEncoder.encode(new String("你在干什么啊? 33335"), "utf-8");?
?????????? System.out.println("0:"+cont);????????????
?????????? String after=URLDecoder.decode(cont, "utf-8");?
?????????? System.out.println("1:"+after);?
????????????
????? } catch (Exception e) {?
??? System.out.println(e.getMessage());?
??? }?
}?

热点排行