我写在strings.xml
文件中的以下内容:我怎么能写字符和android系统的strings.xml
The reference to entity "Drop" must end with the ';' delimiter.
如何我写的字&中:我有以下错误
<string name="game_settings_dragNDropMove_checkBox">Move by Drag&Drop</string>
strings.xml?
我写在strings.xml
文件中的以下内容:我怎么能写字符和android系统的strings.xml
The reference to entity "Drop" must end with the ';' delimiter.
如何我写的字&中:我有以下错误
<string name="game_settings_dragNDropMove_checkBox">Move by Drag&Drop</string>
strings.xml?
对其进行编码:
&
对于特殊字符我通常使用Unicode定义为 '&',例如:\ u0026如果我是正确的。这里是一个很好的参考页面:http://jrgraphix.net/research/unicode_blocks.php?block=0
你可以在这个页面找到所有的HTML特殊字符http://www.degraeve.com/reference/specialcharacters.php只需要替换你想放置那个字符的代码即可。 :-)
getString()不转换"我必须使用\ u0022 – garnet 2016-08-27 15:43:18
也可以把你的字符串的内容转换为XML CDATA,如Android工作室为您做的,当你Extract string resource
<string name="game_settings_dragNDropMove_checkBox"><![CDATA[Move by Drag&Drop]]></string>
这可能是很老了。但对于那些寻找快速代码的人来说。
public String handleEscapeCharacter(String str) {
String[] escapeCharacters = { ">", "<", "&", """, "'" };
String[] onReadableCharacter = {">", "<", "&", "\"\"", "'"};
for (int i = 0; i < escapeCharacters.length; i++) {
str = str.replace(escapeCharacters[i], onReadableCharacter[i]);
} return str;
}
可以处理转义字符,您可以在各自的数组上添加字符和符号。
-Cheers
这是我的问题,我的解决方法是如下:使用>
为<,<
为>,&
为&,"'"
为',"
为\ “\”
它应该是这样的:
<string name="game_settings_dragNDropMove_checkBox">Move by Drag&Drop</string>
要避免错误,使用提取的字符串:
<string name="travels_tours_pvt_ltd"><![CDATA[Travels & Tours (Pvt) Ltd.]]></string>
可以这样写
<string name="you_me">You & Me<string>
输出:您&我
要获取码使用http://www.mikezilla.com/exp0012.html其转换什么你键入,所以不需要查看值 – Entreco 2013-03-06 13:57:06
http://www.mikezilla.com/exp0012.html - >链接断开。 – 2014-10-16 10:51:32
如果使用CDATA,那么请注意,某些字符是保留的。 © - > © 请参阅这篇文章。 http://www.w3schools.com/html/html_entities.asp – toidiu 2015-12-28 19:20:19