1

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:

enter image description here

The Code:

if(tCat.equals("StandardT_")){
     serviceLine="Operations / خدمات عامة";
 }
tv.setText(serviceLine);

what I have tried:

  1. Decoding characters in android and no its not the same question and the answers didn't help.

  2. 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 using ArabicUtilities classes but that didn't work ether

  3. I 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!

  1. 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!

Community
  • 1
  • 1
Ahmad Sanie
  • 3,678
  • 2
  • 21
  • 56

1 Answers1

3

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.

hasan
  • 23,815
  • 10
  • 63
  • 101