Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e45e41d7 authored by Andrew Solovay's avatar Andrew Solovay Committed by Android Git Automerger
Browse files

am 44fa5e71: am 5b3152cf: Merge "Docs: Correcting section on how to escape...

am 44fa5e71: am 5b3152cf: Merge "Docs: Correcting section on how to escape quotes in strings." into lmp-docs

* commit '44fa5e71':
  Docs: Correcting section on how to escape quotes in strings.
parents 24ccb900 44fa5e71
Loading
Loading
Loading
Loading
+23 −7
Original line number Original line Diff line number Diff line
@@ -401,19 +401,35 @@ android.content.res.Resources#getQuantityString(int,int) getQuantityString}.</p>
format and style your string resources.</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
<p>
whole string in the other type of enclosing quotes. For example, here are some stings that
  If you have an apostrophe (<code>'</code>) in your string, you must either
do and don't work:</p>
  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>
<pre>
&lt;string name="good_example">"This'll 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="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">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>
</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>
<h3>Formatting strings</h3>