Winter is coming :
I have the following code:
int color = 0;
int number = 0;
// ...
s = String.format("%dproduct%d", color, number);
This works fine on my computer and on my Android device. I get strings like 0product0
etc.
BUT in production, on users' Android devices, I get strings like:
٠product٠
٠product١
٠product٢
٠product٣
٠product٤
Does String.format() not work OK when starting with a number?
Ralf Kleberhoff :
The strings you get are "correct" for an Arabic Locale, as e.g. the UTF-8 dual-byte value d9 a0
(as posted by Andy) encodes the Unicode code point U+0660
, being the ARABIC-INDIC DIGIT ZERO
.
As the rest of your output isn't locale-dependent, you probably want the numbers shown in US Locale as well, as proposed by Hitesh Sarsava:
String s = String.format(Locale.US, "%dproduct%d", color, number);
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=442516&siteId=1