gpt4 book ai didi

xml - 是否应该只在 UTF-8 XML 中转义特定字符?

转载 作者:行者123 更新时间:2023-12-04 06:06:30 25 4
gpt4 key购买 nike

在 XML 属性中存储以下文本的正确方法是什么?

文本:

", à,é,è, <

输出 1(全部转义)
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>test</title>
</head>
<body>
<outline text="element" _note="&quot;, &#224;,&#233;,&#232;, &lt;">
</outline>
</body>
</opml>

输出 2( only XML specific characters 转义)
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>test</title>
</head>
<body>
<outline text="element" _note="&quot;, à,é,è, &lt;">
</outline>
</body>
</opml>

这两个都有效吗?

最佳答案

是的,它们都是有效的,并且是等效的。使用数字字符引用的主要原因是它们不太可能因不适当的转码而损坏。

关于xml - 是否应该只在 UTF-8 XML 中转义特定字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8291528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com