问题
I'm working on an android app that displays a textviews
with mixed Arabic and English words;
the app displays Arabic text that I wrote inside Java classes as question marks ????? here is a screenshot:
The Code:
if(tCat.equals("StandardT_")){
serviceLine="Operations / خدمات عامة";
}
tv.setText(serviceLine);
what I have tried:
Decoding characters in android and no its not the same question and the answers didn't help.
How to support Arabic text in Android? I'm using a new version that supports Arabic and I also tried the answer like adding
Farsi
Class or usingArabicUtilities
classes but that didn't work etherI also tried to encode String into utf-8
try { serviceLine= URLEncoder.encode(serviceLine, "utf-8");} catch(UnsupportedEncodingException e){ e.printStackTrace(); }
and that didn't work!
- also tried using multiple fonts but not a single Typeface solved the problem.
So I'm kind of stuck here, any ideas?
Edit: After I closed android studio and reopened the app all of the text that I wrote inside the Java classes turned to question marks! Even though I tried to write it again, once I closed the project and reopened it, it displays the Arabic text as question marks inside the Java classes before even I run the application and this is really awkward!
回答1:
You need to set the file encoding of the file that contains the arabic text to UTF-8.
This is how you change file encoding from inside Android-Studio.
来源:https://stackoverflow.com/questions/31178878/text-view-displays-arabic-characters-as-question-marks