summaryrefslogtreecommitdiffstats
path: root/docs/html/guide
diff options
context:
space:
mode:
authorAndrew Solovay <asolovay@google.com>2015-04-02 15:10:51 -0700
committerAndrew Solovay <asolovay@google.com>2015-04-08 12:00:42 -0700
commit3aba19a6c0f2b4473e82330870e7951f57746456 (patch)
tree91315026110bf427a9be0414540192092589ee17 /docs/html/guide
parentff4c632592cce177997d63b3ff81c0b2be9cf9bb (diff)
downloadframeworks_base-3aba19a6c0f2b4473e82330870e7951f57746456.zip
frameworks_base-3aba19a6c0f2b4473e82330870e7951f57746456.tar.gz
frameworks_base-3aba19a6c0f2b4473e82330870e7951f57746456.tar.bz2
Docs: Correcting section on how to escape quotes in strings.
The behavior for single and double-quotes is different--I expanded this section to note how they differ. (New version of a Gerrit CL I abandoned because of a commit mess-up.) See first comment for doc stage location. bug: 19959941 Change-Id: I417546a473f0ebe76a6e4102b87883a85365ac26
Diffstat (limited to 'docs/html/guide')
-rw-r--r--docs/html/guide/topics/resources/string-resource.jd30
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>
-&lt;string name="good_example">"This'll work"&lt;/string>
-&lt;string name="good_example_2">This\'ll also work&lt;/string>
+&lt;string name="good_example">This\'ll work&lt;/string>
+&lt;string name="good_example_2">"This'll also work"&lt;/string>
&lt;string name="bad_example">This doesn't work&lt;/string>
-&lt;string name="bad_example_2">XML encodings don&amp;apos;t work&lt;/string>
+ &lt;!-- 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>
+&lt;string name="good_example">This is a \"good string\".&lt;/string>
+&lt;string name="bad_example">This is a "bad string".&lt;/string>
+ &lt;!-- Quotes are stripped; displays as: This is a bad string. -->
+&lt;string name="bad_example_2">'This is another "bad string".'&lt;/string>
+ &lt;!-- Causes a compile error -->
+</pre>
<h3>Formatting strings</h3>