FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Integration
(Moderators: fry, REAS)
   utf-8 to iso-8859-2
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: utf-8 to iso-8859-2  (Read 2545 times)
eskimoblood

222550793222550793 WWW
utf-8 to iso-8859-2
« on: Mar 11th, 2005, 1:17pm »

I've got a xmlString from a server which is utf-8 encoded. Now I try convert it to iso-8859-2:  
Code:

String s;//paresed XML String
byte[] b=s.getBytes("iso-8859-2");
s=new String(b);

It works fine to encode a String. But it doesent work to convert a string from utf to iso.
 
eskimoblood

222550793222550793 WWW
Re: utf-8 to iso-8859-2
« Reply #1 on: Mar 14th, 2005, 1:48pm »

I figured out:
 
Code:

String utfString="Mönchengladbach";
 
byte[] b=utfString.getBytes();
String s=new String(b,"utf-8");
byte[] c=s.getBytes("iso-8859-2");
String t=new String(c);
 
or short:
 
String t=new String(new String(utfString.getBytes(),"utf-8").getBytes("iso-8859-2"));
« Last Edit: Mar 14th, 2005, 1:48pm by eskimoblood »  
Pages: 1 

« Previous topic | Next topic »