Java:UTF-8和BOM [英] Java: UTF-8 and BOM

查看:237
本文介绍了Java:UTF-8和BOM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java的Bug数据库页面上 http://bugs.sun.com/view_bug .do?bug_id = 4508058 它表明Sun / Oracle不会解决Java无法解析UTF-8编码字符串的BOM的问题。由于此页面上的最新评论可以追溯到2010年,我想知道是否有更年轻的信息? Java无法处理UTF-8的BOM吗?

On a page of Java's Bug Database http://bugs.sun.com/view_bug.do?bug_id=4508058 it reads that Sun/Oracle will not fix the problem of Java not parsing the BOM of a UTF-8-encoded string. Since the most recent comment on this page dates back to 2010, I would like to know if there is any younger info about that? Is it still true that Java cannot handle BOM of UTF-8?

推荐答案

是的,Java无法处理UTF8编码文件中的BOM。在解析多个XML文件以进行数据格式化时,我遇到了这个问题。由于您无法知道何时可能遇到它们,如果您在运行时找到它或遵循tchrist给出的建议,我建议剥离BOM标记。

Yes, it is still true that Java cannot handle the BOM in UTF8 encoded files. I came across this issue when parsing several XML files for data formatting purposes. Since you can't know when you might come across them, I would suggest stripping the BOM marker out if you find it at runtime or following the advice that tchrist gave.

这篇关于Java:UTF-8和BOM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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