Sunday, April 21, 2013

Support Apostrophes in Android Application names \ strings.xml file

Hello,

If you want to support apostrophes in your Android application name (or another field in your strings.xml file) and have got an error, take a look at the information below.

Application names do not support the apostrophe by default. An application name in the strings.xml file (res > values > strings.xml) in the format:


<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Who's there</string>

Will give you an error.

If you want to support this you can try escaping the apostrophe:


<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Who\'s there</string>
(this hint is already there in Eclipse if you hover the mouse over the red cross in the strings.xml file)

else you can enclose the full name in double quotes:


<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">"Who's there"</string>



Hope this helps and makes your life easier ! :)




No comments:

Post a Comment