2

I have a configuration.xml file which I hold all the (yep, you guessed it!).. configuration strings and values and stuff.

One of those values is a string which is an oauth client id, and it has a hyphen..

<string name="server_clientid">5467656-blahblahblah.apps.googleusercontent.com</string>

Now I get the warning message..

Replace "-" with an "en dash" character (–, &#8211;) ?

Ok fair enough, but if I escape with this then the client id is not valid when I fetch it within the app. I can't use & #8211; basically. How do I get around this?

Eurig Jones
  • 8,226
  • 7
  • 52
  • 74

3 Answers3

8

You wrap your values in

<![CDATA[ ]]> 

which stops the parser from parsing the contents. E.g.

<string name="server_clientid"><![CDATA[ 5467656-blahblahblah.apps.googleusercontent.com ]]></string>
dKen
  • 3,078
  • 1
  • 28
  • 37
7

You can also suppress the lint warning (which is false since the dash is not used in a typographical context):

<resources xmlns:tools="http://schemas.android.com/tools">

 ...

<string name="server_clientid" tools:ignore="TypographyDashes">5467656-blahblahblah.apps.googleusercontent.com</string>
laalto
  • 150,114
  • 66
  • 286
  • 303
0

The "n dash" (–, –) and the "m dash" (—, —) characters are used for ranges (n dash) and breaks (m dash). Using these instead of plain hyphens can make text easier to read and your application will look more polished.

Replace smaller "-" with bigger "". You are good to go.

Srikar Reddy
  • 3,650
  • 4
  • 36
  • 58