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

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

问题描述

是否有任何免费的 Java 库可用于将一种编码的字符串转换为另一种编码,例如 图标?我使用的是 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? I'm using Java version 1.3.

推荐答案

您不需要超出标准的库 - 只需使用 字符集.(您可以只使用 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 方法:新字符串(字节,字符集)字符串.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).

请参阅URL 编码(或:'那些是什么%20" 网址中的代码?')".

See "URL Encoding (or: 'What are those "%20" codes in URLs?')".

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

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