Gkapoor
Gkapoor

Reputation: 850

How to show Hindi text in android?

I am trying to paste Hindi characters in an array with elements like
String[] arr = {"आपका स्वागत है","आपका स्वागत है"};
but its giving error i.e.
"some characters cannot be mapped using "Cp1252" character encoding"
while saving this.

Upvotes: 5

Views: 9000

Answers (4)

Gkapoor
Gkapoor

Reputation: 850

Thanks i found the solution...

  1. Create an array under the value folder

  2. Use the font that support Hindi under the assets folder

  3. textview.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/Hindi.ttf"));

its working fine...

Upvotes: 0

Gkapoor
Gkapoor

Reputation: 850

Thanks i found the solution...

  1. create an array under the value folder
  2. Use the font that support Hindi under the assets folder
  3. textview.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/Hindi.ttf")); its working fine...

Upvotes: 3

Jacob Ewald
Jacob Ewald

Reputation: 2178

Switch your text encoding to UTF-8.

In Eclipse go to Window -> Preferences, select General -> Workspace. From the Text file encoding dropdown, select UTF-8.enter image description here

Upvotes: 4

duffymo
duffymo

Reputation: 308753

You need UTF-8 encoding, not Cp1252, and Unicode.

Upvotes: 0

Related Questions