I have some XML that looks like the following sample:
<?xml version="1.0" encoding="....."?>
<music>
<song>
<id>1</id>
<title>العقائد </title>
<duration>عدد الكتب: 10</duration>
</song>
</music>
when I run my app, it shows me weird characters. I'm wondering how to parse Arabic characters?
Android can't handle the basic unicode characters 0x6--. If you want to display the arabic characters correctly, you will need to use Arabic Presentation B characters 0xFE--. These characters do not join together automatically- you have to do that yourself.
You will also need to use a font that supports these characters. There is a good Deja Vu font, or you can use "AGA Rasheeq Bold"- and put it into your assets, then load it like this
Typeface tfArabic = Typeface.createFromAsset (getAssets (), "AGA-Rasheeq-Bold.ttf");
Then use something like this to use the font:
textview.setTypeface (tfArabic);
>
characters. I also moved the closing tag<\song>
and included the missing</music>
. If the</music>
tag was missing from your actual input then that would explain trouble parsing - RBerteig 2012-04-05 01:03