xml:日语编码
我正在制作一个包含日语字符串的 xml 文档。我尝试过不同的编码,但每次保存文件时,它都会用“??????”替换日文字符串。我这里有一个非常简短的示例代码。请告诉我应该使用什么编码xml 文档。
<?xml version="1.0" encoding="utf-8"?>
<config>
<start_text>転送</start_text>
</config>
请告诉我应该使用什么编码,以便即使在保存并关闭 xml 文档后仍保留日语字符。 谢谢大家
I am making an xml document with japanese strings in it. I have tried different encodings but everytime when I save the file, it replaces the japanese strings with "??????".. I have a very brief sample code here.. Please advise me towards what encoding should I use for the xml doc.
<?xml version="1.0" encoding="utf-8"?>
<config>
<start_text>転送</start_text>
</config>
Please advise me regarding what encoding should I use so that the japanese characters are retained even after saving and closing the xml doc.
Thanks all
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 XML 文件中有两个日语字符,您会看到六个问号。正如您在 XML 文件中提到的,这听起来像 UTF-8 编码。有几种可能性:
读取 XML 文件的程序使用 ASCII 编码来读取它,因此用问号替换 ASCII 范围之外的每个字节。
该程序正确读取 XML 文件,但随后使用 ASCII 编码将 UTF-8 编码的字节打印到某个输出通道,并用问号替换每个超出范围的字节。
(旁注:如果输出是
è»entié??
,它将以 UTF-8 格式打印到 ISO-8859-1 输出通道。但它似乎是六个问号。)您需要找出发生以下转换的位置:
There are two Japanese characters in your XML file, and you get six question marks. This smells like UTF-8 encoding, as mentioned in your XML file. There are several possibilities:
The program that reads the XML file reads it with encoding ASCII, and therefore replaces every byte outside the ASCII range with a question mark.
The program reads the XML file properly, but then prints the UTF-8 encoded bytes to some output channel using the ASCII encoding, replacing each out-of-range byte with a question mark.
(Side note: If the output were
転é??
it would be UTF-8 printed to an ISO-8859-1 output channel. But it seems to be six question marks.)You need to find out at which places the following transformations happen: