Escaping single quotes in resource xml for Android

心已入冬 提交于 2019-12-19 05:23:38

问题


I have a file with strings in my ../res/values/strings.xml, which I try to source for my project. This works fine with normal texts. Problem : I have single quotes in my texts and I try to escape them. Many sources suggest to escape it with ' in XML Files.

But this does not work for me in my Eclipse Android Project. When I do a clean project, it shows errors in my Code. (R.class)

<string name="mystring_id">&apos;Hello&apos;</string>

Howto escape properly ?


回答1:


You can use \' in your string resources.




回答2:


Use double quotes:

<string name="mystring_id">"'Hello'"</string>



回答3:


you need to escape the apostrophe by using

\ before '

etc didn't should be like

didn\'t


来源:https://stackoverflow.com/questions/25311521/escaping-single-quotes-in-resource-xml-for-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!