Java下unicode转换为utf-8

2014/05/29 09:56
阅读数 1.4W
参考自: http://stackoverflow.com/questions/4184108/python-json-dumps-cant-handle-utf-8

try {
    String s1 = "\u5e7f\u5c9b\u4e4b\u604b.mp3";
    byte[] converttoBytes = s1.getBytes("UTF-8");
    String s2 = new String(converttoBytes, "UTF-8");
    System.out.println(s2);
} catch (Exception e) {
	e.printStackTrace();
}

会输出:

广岛之恋.mp3





展开阅读全文
加载中
点击加入讨论🔥(4) 发布并加入讨论🔥
打赏
4 评论
3 收藏
0
分享
返回顶部
顶部