Weird characters while displaying hindi text in android

3.5k views Asked by At

I want to display some text in hindi that I am getting from server.

While showing the text some weird characters are displayed (à¤à¥à¤¸à¥à¤à¤¿à¤à¤). But in iOS its showing perfectly

I think its some encoding issue

3

There are 3 answers

2
Karthik K M On BEST ANSWER

Finally got an answer myself I am using volley as my networking library and by default its encoding was in latin-1 So after changing to utf-8 it worked perfectly

Thanks everyone for your help

0
Vishal Chauhan On

By default Android phone (Now some does support) doesn’t support Devanagari fonts. However if you want to use hindi, tamil, bangali or other Devanagari fonts in your Android Application you have an alternative of using external fonts.

Follow these steps...

  1. Download an external Devanagari font that you like to use in your application. ex. (Verdana.ttf or anand-lipi-bold)

  2. Create a new folder “fonts” under assets and copy the downloaded .ttf font to your assets/font folder.

then Load .ttf to your TextView.

TextView tv = (TextView) findViewById(R.id.textView);
    Typeface fontHindi = Typeface.createFromAsset(getAssets(),
            "fonts/Ananda Lipi Bold Cn Bt.ttf");
    tv.setTypeface(fontHindi);
    tv.setText("Hindi font");

Hope this will help you.

1
bindal On

Please use below Code for getting string

new String("Your String".getBytes("ISO-8859-1"), "utf-8")

I was also getting some arabic string from server and it was displaying some chaaracters like yours but after using this it solved

Here instead of ISO-8859-1 you can use encode type in which data is encoded on server side