Read XML in ISO-8859-1 and move to UTF-8 (Android Studio)

1

I am creating an application in Android Studio. This connects to a web and receives an xml that is in ISO-8859-1 . The application uses UTF-8 .

It is impossible for me to paint the tildes, ñ, etc. I've used URLDecode.decode, xmlString.getBytes("ISO-8859-1"),"UTF-8") , and I always miss those characters, always Denominaci?n, Espa?a, etc .

My question is, even if it is in ISO-8859-1, does it receive the xml in that encoding, or does it transform it to UTF-8 ?, I do not know if it's explained to me.

Some idea of how to solve this. Thanks to everyone.

    
asked by Anllares 09.11.2018 в 19:20
source

1 answer

0

You can do it this way, using the methods new String (byte [] bytes,       Charset charset and getBytes (Charset charset) to convert from ISO-8859-1 to UTF-8 :

byte[] valorISO88591;
...
...
//*Convierte ISO-8859-1 a UTF-8.
byte[] valorUtf8 = new String(valorISO88591, "ISO-8859-1").getBytes("UTF-8");
    
answered by 09.11.2018 / 21:30
source