XML文件编码格式“utf-8” VS“UTF-8”?
当 XML 文件转换为 ASCII 时。 utf
和UTF
这三个字符对于用户来说是不同的值。
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="UTF-8"?>
我尝试用vs2005创建一个新的xml文件。默认生成utf-8
表单文件。
哪一个是更标准的定义?谢谢。
When the XML file was convert to ASCII. It is different values for user at the three characters of utf
and UTF
.
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="UTF-8"?>
I tried to create a new xml file with vs2005. utf-8
form file generated by default.
which one is a more standard definition? thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
IANA 字符集注册表表示:
但是该页面、XML 规范和unicode.org 对于大写 UTF-8 是一致的。
The IANA character set registry says:
But that page, the XML specification, and unicode.org are consistent about capitalizing UTF-8.
来自 XML 规范:
“XML 处理器应该匹配不区分大小写的字符编码名称way”
这表示您可以根据需要使用大写或小写,甚至混合大小写。但是,该规范在所有示例中都使用“UTF-8”,因此为了保持一致性,我会使用“UTF-8”。
From the XML specification:
"XML processors SHOULD match character encoding names in a case-insensitive way"
This indicates that you can use upper case or lower case or even mixed case if you wish. However, the specification uses "UTF-8" in all its examples so for consistency I'd go with that.
对于那些对血淋淋的细节感兴趣的人 - 包括一些相关标准和先例的链接 - 几年前我在博客上写了关于 XML 声明中 UTF-8 的区分大小写。
For those interested in the gory details - including links to some of the related standards and precedents - I blogged a couple of years ago about Case-Sensitivity of UTF-8 in XML Declarations.
根据我的经验(主要是 .NET),字符集标识符被视为不区分大小写,因此
UTF-8
和utf-8
以及UTF-8
或其任何其他变体,始终表示相同的意思。对于其他字符集,例如ISO-8859-1
(Latin 1) 等,情况也是如此。大小写应该无关紧要,因为大小写在此类标识符中不是一个有意义的因素。我对跨多个平台的 Web 服务进行了大量工作,但我从未真正见过使用的“标准”形式。我见过各种字符集的各种变体……通常是来自单个业务合作伙伴的不同变体。
In my experience (which is primarily with .NET), character set identifiers are treated as case-insensitive, so
UTF-8
andutf-8
, as well asUtf-8
or any other variation thereof, always mean the same thing. This would also be the case for other character sets, such asISO-8859-1
(Latin 1), etc. The casing should not matter, as case is not a meaninful factor in such an identifier.I do extensive work with web services across multiple platforms, and I have never really seen a "standard" form used. I've seen every variation of a variety of character sets...often different variations from a single business partner.
大写是事实上的标准。但是,它仍然适用于任意大小写组合。
Upper-case is the de-facto standard. It should still work with any combination of case, however.