Search code examples
androidstringkotlinsymbols

Can't get rupee symbol to show correctly from strings.xml


So this works fine:

strFoo = "\u20B9" + strBar

But this doesn't

strFoo = R.string.rupee_symbol.toString() + strBar  //.toString() is required

//R.string.rupee_symbol.toString() evaluates to some random number 2131755148... which I believe is a character array... 

strings.xml

<string name="rupee_symbol">\u20B9 </string>

I can't figure out why it would behave like that, it looks like the same thing...!


Solution

  • You should not concatenate strings with string resources instead, you can use place holder:

    <string name="rupee_symbol">\u20B9%s</string>
    

    And use:

    strFoo = resources.getString(R.string.rupee_symbol, strBar)