Friday 15 June 2012

java - Convert and Display the UTF8 Encoded String -


I have a JSON response, which I want to store in DB and display in text view or edit text . This JSN answer is encoded with UTF-8 format.

The reaction is something like this:

  "currencies": [[, "RUR", "", 1,0], [1, "euro", "a  € "1.44,100], [2," GBP "," one £? ", 1.6,100], [3," JPY "," one "¥", 0.0125,100], [4] , "AUD", "$", 1.1, 100]]   

Where à ¢ one, a ??, a ?? ¥ currency symbol, I have to decode it and then display These symbols are symbols in Unicode (TransFord as UTF 8). How can I change this encoded symbol? Plz help.

I try to do this But it does not work:

  byte [] b = string symbol .get bits ("utf-8"); // one ¢ one, one ?? one pound, one ¥ final String str = new string (b);    

you text Symbols are showing with non-currency ... It seems that you are taking the original text, then encoding that as UTF-8, then decoding it is ISO-8859-1 In form.

This is just text - you have to do anything after that. Do not need, and you should never see it in the broken form. If you have to convert the text back into bytes and then again for a string, this means that you have already lost, basically.

Check the header on the HTTP response that gives JSON - I suspect you will find 'it is claiming that it is claiming ISO-8859-1 data instead of UTF-8. The real encoding should match the encoding specified in the headers, otherwise you end up with such effect.

Another possibility is that whatever JSON is returning is giving you the correct data that knows about this , and that the data has broken upstream You should follow the data phase from the stage (assuming you consider all the links in the series) until you can see how you are facing this breakdown.

No comments:

Post a Comment