1

In my Android application I am trying to display German Text. ö ä ü ß those characters are unable to display in TextView. If anyone having idea how to set font or how to display characters let me know. The Data I am receiving from services.

Tim Büthe
  • 62,884
  • 17
  • 92
  • 129
Abhishek Karande
  • 377
  • 3
  • 10
  • 19
  • possible duplicate of [What is character encoding and why should I bother with it](http://stackoverflow.com/questions/10611455/what-is-character-encoding-and-why-should-i-bother-with-it) – Raedwald Apr 10 '15 at 12:36

2 Answers2

4

I think you should read wikipedia: Character_encoding as well as The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

Tim Büthe
  • 62,884
  • 17
  • 92
  • 129
  • Hello Im parsing xml and the data inside xml is german well my xml is UTF-8 Im parsing by DOM parser. Data is correct but while reading data from xml it reads german character as garbage symbols. Do u have any clue what to do??? – Abhishek Karande Dec 06 '11 at 06:19
  • 1
    Show us some code and show us what the characters look like. I think this must be an encoding problem, do you have characters like this: `â€` and `é`? Normally, when you have UTF-8 data and read it with, let's say ISO-8859-1, you end up with two characters instead of the one you would expect. What makes you think your XML is utf-8, because the header says so? – Tim Büthe Dec 06 '11 at 09:44
  • 1
    @AbhishekKarande: I didn't down vote that, but I didn't upvoted it either. That said, I think your question could use some code as well as the expected and actual outcome. – Tim Büthe Dec 06 '11 at 15:15
0

My problem solved I add

DocumentBuilder db = dbf.newDocumentBuilder(); ByteArrayInputStream bis = new ByteArrayInputStream(xml.getBytes("UTF-8")); doc = db.parse(bis); in my code in xml reader so now I can display german characters properly...

Abhishek Karande
  • 377
  • 3
  • 10
  • 19
  • 1
    I'm glad your problem is fixed but it may not be the ideal solution. What you're doing is this: You have your XML as a String (I suppose) and make a byte[] out of it, by calling `getBytes(...)`. Then you hand this to the parser. This might work for small amounts of data, but may fail with bigger. Where does the XML come from? When you receive it from a webserver or read it from a file, you could get the stream when right then and hand that to your parser. – Tim Büthe Dec 06 '11 at 15:21