Reputation: 1092
If i try to do things like this, it doesn't work... (empty string or no resource type error)
<string name="make_sales_order">FAIRE L'ORDRE DE VENTE </string>
how to use apostrophe character in android string xml.any ideas?
Upvotes: 12
Views: 17858
Reputation: 680
The curved apostrophe is a little more professional for user-facing messaging than the straight one mentioned above. The unicode for start and end curved apostrophes is 2018
and 2019
. In Android strings.xml, you preface with a \u
, u\2019
For example: The possessive word Bob's would be: <string>Bob\u2019s</string>
Here is a reference for punctuation UTF codes: https://symbl.cc/en/unicode/blocks/general-punctuation/
Upvotes: 1
Reputation: 3798
1. For Single Quote (')
You can use \'
in your string resources.
or
You can enclose the string in double quotes. For example:
"This'll work"
will simply become This'll work
once parsed
2. For double quote (")
"message \"quote string 1\" and \"quote string 2\" end message"
3. To represent in views xml (eg layout.xml), you have to use HTML character entities (like ")
"message "quoted string 1" and "quoted string 2" end message"
Though Android Studio in particular will complain about hardcoded strings and tell you to use a string resource in layout files instead of course!
Upvotes: 25
Reputation:
Use \' in your string.xml
<string name="make_sales_order">FAIRE L\'ORDRE DE VENTE </string>
Upvotes: 8
Reputation: 709
<string name="make_sales_order">FAIRE L\'ORDRE DE VENTE</string>
Upvotes: 1