Android Hebrew RTL String With Numeric Value Flipped
Asked Answered
W

2

7

I would like to display a String with my app name and it's current version. The app name is in hebrew, for some when I combine hebrew text with numeric value, the numeric value is flipped.

versionTextView.setText("אפליקציה גרסה "+this.getResources().getString(R.string.app_version));

for example: app version is 1.0, being display as 0.1 on emulator.

Wirewove answered 5/8, 2012 at 8:57 Comment(0)
H
13

Sounds like a bug in the Android bidi algorithm. Try adding left-to-right marks around the numbers:

versionTextView.setText("אפליקציה גרסה "
    + "\u200e"
    + this.getResources().getString(R.string.app_version)
    + "\u200e"
);

(If this works, you may be able to eliminate the second one.)

Hydrolyse answered 5/8, 2012 at 9:3 Comment(2)
Thanks, that works but '\u200e' adds a strange char to the stringWirewove
@Wirewove - That sounds like a font problem on top of the bidi algorithm bug. The only thing I can suggest is to try a different font. You might have to package your own font with your app to have control over this. There are some free fonts for Hebrew. Ezra SIL is an excellent font with a classical look. You can find many others with a simple web search.Hydrolyse
G
0

I think that tou need to style the output string with a CSS using the dir="RTL" tag - that will fix the directionality of your numbers and special characters inside Hebrew

Galligan answered 27/8, 2013 at 6:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.