在java中编码转换 [英] Encoding conversion in java

查看:120
本文介绍了在java中编码转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有任何免费的Java库,我可以使用将一个编码中的字符串转换为其他编码,像php中的iconv?我使用的是java版本1.3。

Is there any free java library which I can use to convert string in one encoding to other encoding, something like iconv in php? I'm using java version 1.3.

推荐答案

你不需要一个超出标准的库 - 只需使用 Charset 。 (你可以只使用String构造函数和getBytes方法,但我个人不喜欢只使用字符编码的名称。打字错误的空间太大了。)

You don't need a library beyond the standard one - just use Charset. (You can just use the String constructors and getBytes methods, but personally I don't like just working with the names of character encodings. Too much room for typos.)

编辑:正如评论中所指出的,您仍然可以使用Charset实例,但可以方便地使用String方法: new String(bytes,charset) and String.getBytes(charset )

As pointed out in comments, you can still use Charset instances but have the ease of use of the String methods: new String(bytes, charset) and String.getBytes(charset).

这篇关于在java中编码转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆