org.springframework.oxm.jaxb.Jaxb2Marshaller 元音变音和特殊字符
如何使用以下方式编组包含变音符号的 java 字符串对象 org.springframework.oxm.jaxb.Jaxb2Marshaller ? 我有像 Alizée
这样的 java 字符串。 使用 Jaxb2Marshaller 编组后,我得到 Alizée
xml 字符串。
How can I marshal java string object that contain umlauts by using
org.springframework.oxm.jaxb.Jaxb2Marshaller ?
I have java string like Alizée
.
After marshalling with using Jaxb2Marshaller i get Alizée
xml string.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是正确的,但您正在使用错误的字符集对编组的 XML 进行编码(您将 UTF-8 视为 ISO-8859-1/扩展 ASCII)。
我会仔细检查字符编码,并确保您正在使用正确的编码查看编组的 XML。
示例: é 采用 UTF-8 格式,由两个字节表示:
0xC3
0xA9
http://www.fileformat.info/info/unicode/char/00e9/index.htm这两个字节,表示为例如 ISO-8859-1 将读取:
0xC3
: à http://ascii-table.com/info.php?u=x00C30xA9
:© http://ascii-table.com/info.php?u=x00A9如果创建文本文件包含 é 并将其保存为
UTF-8
。重新打开文件,但选择编码ISO-8859-1
,您将看到相同的内容。This can be right, but you are vieving the marshalled XML with the wrong charset (you view UTF-8 as ISO-8859-1/extended ASCII).
I would double-check character encodings and that you are viewing the marshalled XML with the correct encoding.
Example: é is in UTF-8 represented by two bytes:
0xC3
0xA9
http://www.fileformat.info/info/unicode/char/00e9/index.htmThese two bytes, represented in for example ISO-8859-1 will read:
0xC3
: Ã http://ascii-table.com/info.php?u=x00C30xA9
: © http://ascii-table.com/info.php?u=x00A9If you create a text file containing é and save it as
UTF-8
. Re-open the file but choose encodingISO-8859-1
and you will see the same.