我有一个可能非常简单、愚蠢的问题,但我在任何地方都找不到答案,我需要对此非常确定。
我有来自不同供应商的各种 XML 文件。 其中一个供应商向我提供了一个 XML 文件,其中包含日语字符。 最初,我在处理 XML 文件时遇到了问题(我正在使用 MSXML SDK)。 字符会出现错误。 我发现如果将以下内容添加到 XML 文件中,一切都会很好。
<?xml version="1.0" encoding="UTF-16"?>
所以我要求供应商将其添加到他们的文件中。 但他们用小写编码添加了它:
<?xml version="1.0" encoding="utf-16"?>
当我使用此声明加载这个新文件时,我遇到了与不存在此声明时相同的问题。
我想弄清楚(当然)是该编码属性是否区分大小写(或者是其他问题)。 他们将“utf-16”与“UTF-16”放在一起重要吗?
更新:在此处发布答案的人的建议下,我设置并执行了测试。 一个文件的 utf-16 为小写,另一个文件为大写。 除此之外,这些文件是相同的。 这并没有解决问题,也不是问题所在。 我的结论是,MSXML 不区分大小写,正如答案中发布的规范所述。
I have what is probably a really simple, studid question but I can't find an answer to it anywhere and I need to be pretty sure about this.
I have various XML files from various vendors. One of the vendors provide me an XML file with japanese characters in the file. Originally, I was having trouble processing the XML file (I'm using the MSXML SDK). The characters would come out wrong. I found that if the following was added to the XML file everything worked great.
<?xml version="1.0" encoding="UTF-16"?>
And so I asked the vendor to add this to their file. But they added it with the encoding in lower case:
<?xml version="1.0" encoding="utf-16"?>
And when I load this new file, with this declaration, I'm getting the same problem as when this declaration was not there.
What I'm trying to figure out (for sure) is if that encoding attribute is case sensitive (or is otherwise the problem). Does it matter that they put "utf-16" versus "UTF-16"?
Update: Under the advise of these who posted answers here, I setup and executed a test. One file had the lower case utf-16 and the other upper case. Other than that, the files were identical. This did not fix the problem and is not the problem. My conclusion is that MSXML is not case sensitive as the spec, posted in the answers, states.
发布评论
评论(2)
我想问题实际上并不是“标准是否区分大小写?” 但是“MSXML SDK 中的编码是否区分大小写?”
来自 bytes.com:
然而,我们知道在实践中这可能并不总是正确的。 如果您可以同时尝试两者,请这样做并让我们知道结果是什么。
I suppose the question is not really "is the standrard case-sensitive?" but "is the encoding case-sensitive in MSXML SDK?"
From bytes.com:
However, we know that this may not always be true in practice. If you can try both side-by-side, please do so and let us know what the result is.
来自 XML 规范:
所以不需要,但建议这样做不区分大小写,根据 RFC 2119:
From the XML specs:
So it's not needed but recommened to be case-insensitive, according to RFC 2119: