Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Russian Ruble currency not displayed on certain phone?

Tags:

android

I am getting some JSON data with a formatted string of currency like this

₽35

However, i noticed that on a Nexus 5 (Lollipop) it displays it correctly but other phones such as the HTC one mini and Samsung GT-I9505, it displays a blank character.

I attempted to research the issue, i could not find a solution other than, in the XML layout file, ensure that this line is present

<?xml version="1.0" encoding="utf-8"?>

But i still have the same issue

Please help

Edit 15 May 2015

Loading custom font NotoSans (Please note I know this would leak memory but its just a quick test)

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView ruble = (TextView)findViewById(R.id.ruble);
        Typeface myFont = Typeface.createFromAsset(getAssets(),"fonts/NotoSans-Regular.ttf");
        ruble.setTypeface(myFont);
    }

The Russian Ruble symbol defined in strings.xml (note I tried all)

     <string name="rubleSymbolJava">\u20BD</string>
  <string name="rubleSymbolHTML">&#8381;</string>
    <string name="rubleSymbolHTMLHex">&#x20bd;</string>

Same problem, on older phones shown as a square but works on Android 5.0 BUT nothing older.

SOLVED Please see my answer

like image 469
Ersen Osman Avatar asked May 14 '15 14:05

Ersen Osman


People also ask

How do you insert a ruble symbol?

Typing the ruble symbol If you don't have a keyboard that supports the ruble symbol, you can insert the ruble currency symbol using one of these: Using Alt-X: Type 20BD, and then hold down the ALT key and press X.

How do you write money in Russia?

The official symbol for the Russian rouble was only adopted in December 2013 and depicts a 'P' (a Russian 'R') with a horizontal cross. Usually you will see prices written as "100 руб." or sometimes just "100 р". The official ISO code for the rouble is 'RUB'.


2 Answers

You can also check Android version. I think, some phones on API 19 support russian rubles, but on API 21 they all support it. It would be easier to add string resources instead of check and replace programmatically.

After reading Trying to use <!ENTITY in ANDROID resources with error: "The entity was referenced, but not declared." I made a new file strings.xml in res/values-v21.

So, in values/strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE resources [
    <!ENTITY rouble "р.">
    ]>
<resources>
    <string name="saaki">Галстук Сааки - %1$s &rouble;</string>
</resources>

In values-v21/strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE resources [
    <!ENTITY rouble "₽">
    ]>
<resources>
    <string name="saaki">Галстук Сааки - %1$s &rouble;</string>
</resources>
like image 53
CoolMind Avatar answered Nov 15 '22 19:11

CoolMind


I fixed this. I just used the new Google Roboto Font which was last updated Jan 2015 and has the Ruble symbol.

https://www.google.com/fonts/specimen/Roboto#pairings

Research showed that in 2014 Russia changed their currency symbol so old fonts did not have the new Glyph so for others who have a similar issue, see if your font has been updated

like image 37
Ersen Osman Avatar answered Nov 15 '22 19:11

Ersen Osman