diff options
author | Andrew Solovay <asolovay@google.com> | 2015-04-02 15:10:51 -0700 |
---|---|---|
committer | Andrew Solovay <asolovay@google.com> | 2015-04-23 13:07:29 -0700 |
commit | a967cade1d399bbd20236f0b76ee9e2098c91c0f (patch) | |
tree | 795a39ab9b65695497dcf3f8108f146dd6597654 /docs | |
parent | 26a8090a09bce05398cc52581ea4a5cf05d28d59 (diff) | |
download | frameworks_base-a967cade1d399bbd20236f0b76ee9e2098c91c0f.zip frameworks_base-a967cade1d399bbd20236f0b76ee9e2098c91c0f.tar.gz frameworks_base-a967cade1d399bbd20236f0b76ee9e2098c91c0f.tar.bz2 |
cherrypick from lmp-docs Docs: Correcting how to escape quotes.
Original Change-Id: I417546a473f0ebe76a6e4102b87883a85365ac26
The behavior for single and double-quotes is different--I expanded
this section to note how they differ.
bug: 19959941
Change-Id: I9be9c066c416e9403a3ac164af0b1ce35f7ab1dd
Diffstat (limited to 'docs')
-rw-r--r-- | docs/html/guide/topics/resources/string-resource.jd | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/docs/html/guide/topics/resources/string-resource.jd b/docs/html/guide/topics/resources/string-resource.jd index cbfa82e..743e692 100644 --- a/docs/html/guide/topics/resources/string-resource.jd +++ b/docs/html/guide/topics/resources/string-resource.jd @@ -401,19 +401,35 @@ android.content.res.Resources#getQuantityString(int,int) getQuantityString}.</p> format and style your string resources.</p> -<h3>Escaping apostrophes and quotes</h3> +<h3 id="escaping_quotes">Escaping apostrophes and quotes</h3> -<p>If you have an apostrophe or a quote in your string, you must either escape it or enclose the -whole string in the other type of enclosing quotes. For example, here are some stings that -do and don't work:</p> +<p> + If you have an apostrophe (<code>'</code>) in your string, you must either + escape it with a backslash (<code>\'</code>) or enclose the string in + double-quotes (<code>""</code>). For example, here are some strings that do + and don't work: +</p> <pre> -<string name="good_example">"This'll work"</string> -<string name="good_example_2">This\'ll also work</string> +<string name="good_example">This\'ll work</string> +<string name="good_example_2">"This'll also work"</string> <string name="bad_example">This doesn't work</string> -<string name="bad_example_2">XML encodings don&apos;t work</string> + <!-- Causes a compile error --> </pre> +<p> + If you have a double-quote in your string, you must escape it + (<code>\"</code>). Surrounding the string with single-quotes does + <em>not</em> work. +</p> + +<pre> +<string name="good_example">This is a \"good string\".</string> +<string name="bad_example">This is a "bad string".</string> + <!-- Quotes are stripped; displays as: This is a bad string. --> +<string name="bad_example_2">'This is another "bad string".'</string> + <!-- Causes a compile error --> +</pre> <h3>Formatting strings</h3> |