Displaying UTF-8 characters in a TextView
Do I have to do anything special to display UTF-8 characters in a TextView?
I'm trying to display the following characters:
זוג, למטרות רומנטיות, מיניות או אחרות, בהתאם להעדפותיהם. אתרי היכרויות מכילים מאגר מידע הכולל פרופיל אישי של מנויים. כל אדם המעוניין להצטרף לשירות, ממלא טופס הרשמה באתר ויוצר לעצמו פרופיל.
If I use Log.d(TAG, text)
where text
contains the characters I'm going to display, it displays correctly in the logcat output. If I then use textview.setText(text)
, all that's displayed in the TextView is boxes.
From what I've been reading, a lot of these fonts, like Hebrew and such aren't supported by Android, 开发者_如何学Pythonhowever, if I send myself an email with these characters, they are displayed correctly in the Gmail and Tiwtter apps.
How can I display these characters correctly?
UPDATE:
I installed the AnySoftKeyboard app, and the Hebrew language pack, and suddenly my app is able to display Hebrew. If I uninstall both of these, my app is still able to display Hebrew. This doesn't make any sense at all to me.
The problem is due to the fonts installed.
If the font being used does not have the Hebrew alphabet you'll see whatever the fon't uses for it's default character (i.e. a box).
As far as I'm aware there isn't a Hebrew font installed by default in all Android distributions, hence why AnySoftKeyboard has a Hebrew language pack that installs a fon't with the Hebrew alphabet.
精彩评论