8

I've created a messaging app and am learning a good portion of members don't reside in North America or the UK.

When they post messages only garbled text is returned. All database columns where the data is store is in UTF-8.

Is there a way to properly display UTF-8 Characters that someone has been able to enter? See the screenshot below.

Android screenshot of invalid characters

Kevin Parker
  • 16,975
  • 20
  • 76
  • 105

1 Answers1

7

The simple one: use the appropriate font.

More precisely, the endpoint should have a font which define the unicode characters if you want to display them properly. I don't know if that is possible for android but you should try to embbed a full utf-8 font with your application since you have no idea on what's defined by the resident font (Droid familiy can be replaced by vendors or power user).

Test with the vanilla Droid family first (you can find it on android.git.kernel.org), find a font family redistributable with your application and use it within your application. I have never used that but it seems to me that handcent provide differents font packs (for look'n'feel but certainly for unicode regions).

Renaud

Can be found on the android git repo: − DroidSansArabic.ttf defining the Arabic interval (U+6000-U+06FF 94/250 and more) − DroidSansHebrew.ttf defining the Hebrew interval (U+0590-U+05FF 87/87) … … (checked with fontforge)

Renaud
  • 8,783
  • 4
  • 32
  • 40
  • Kind of brutal I need to find a font elsewhere to do this. How would I actually change the application / activity / view font into a ttf I've downloaded? – Kevin Parker Feb 27 '11 at 00:03
  • Never done that on android, though I have some experience with digital typography… See [that post](http://stackoverflow.com/questions/3424165/can-i-embed-a-custom-font-in-an-android-application) to begin with… I'm interested by any feedback anyway. – Renaud Feb 27 '11 at 01:20
  • I've still made very little progress with this. I've been able to load 3rd party fonts but the problem seems more complicated now. I've tried using the GNU Unicode font without success, the font is too large to be loaded by the device at a whopping 13MB. It seems like the device has a hard coded 3MB limit. – Kevin Parker Feb 27 '11 at 03:08
  • This might not just be a font issue. I've added the DroidSans file found along with the Android SDK and applied it to the TextView. Still, the characters appear as boxes. – Kevin Parker Feb 27 '11 at 05:45
  • Did you try to substitute DroidSans by one of the DroidSans{Japanese|Hebrew|Arabic}, knowing the intervals needed to correctly display the input text? I don't remember where I read that but most of desktop fonts will not be adapted to android (bad kerning and like)… It will be good to make a sample unitary application with static utf-8 texts to check unicode intervals coverage (added to my maybe/someday list ;) ) – Renaud Feb 27 '11 at 13:03
  • I'm not about the apply a different font on a per TextView basis dependent on the language involved. It would be ideal if I could simply apply one font that contains the major languages of the world like the GNU Unifont (which it too large). – Kevin Parker Feb 28 '11 at 04:47