Android: Arabic XML Parsing?

Go To StackoverFlow.com

1

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?

2012-04-05 00:51
by Ali
I fixed the quoted XML to be a code block rather than a broken blockquote, which removed a bunch of excess > 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
My actual input was not having any trouble , I just was having it here .. sorr - Ali 2012-04-05 01:06
No worries. It looked wrong enough that I confidently fixed the formatting for you. But I wanted to call your attention to it in case I was changing the meaning of your question, and to show you a better way to format the example in a question. It takes a while to get the hang of the Markdown syntax used here at SO, but it is worth it.... Unfortunately, I don't have any answers for your actual question - RBerteig 2012-04-05 01:08


0

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);
2015-02-28 22:09
by JavaLatte
Ads