We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › change xml encoding
Page Index Toggle Pages: 1
change xml encoding (Read 805 times)
change xml encoding
Oct 11th, 2005, 4:32pm
 
Hi guys, I'm using nanoxml lite to parse an xml that is generate from a server. I asked to generate the xml using as encoding iso-8859-1 but I have problem with special characters (òàùèì, for instance). To make a test I downloaded the file and I saved as utf-8 but now p5 gives me an error:

Code:
java.lang.RuntimeException: nanoxml.XMLParseException: XML Parse Exception during parsing of the XML definition at line 1: Expected: < 



Does someone have a clue on what happen? would you suggest me to make the server generate a utf-8 xml?


cheers, chr
Re: change xml encoding
Reply #1 - Oct 11th, 2005, 6:03pm
 
Thanks to Toxi I realized that first my shitty editor instead of saving the file as utf-8 saved it at utf-8y :S
So after saving it properly p5 doesn't give anymore the error, but I can't see properly the special characters (the same point I was without utf-8 encoding of the file).
It shouldn't be a problem with PFont because if I put the special character with my text editor in a non utf-8 encoded xml, they are shown correctly.

Any idea?


thanks, chr
Re: change xml encoding
Reply #2 - Oct 11th, 2005, 6:56pm
 
so i figured out this problem has actually to do with the fact loadStrings() doesn't specify a decoder for its InputStreamReader() instance... This is potentially an obstacle for international users, so maybe we could have an overloaded version of loadStrings(), in which one can specify a character encoding format explicitly? like:

loadStrings("hello.xml","UTF8"); or
loadStrings("hello.xml","8859_1");

and then in PApplet.loadStrings() change line 3268 to:
Code:
BufferedReader reader = new BufferedReader(
new InputStreamReader(input,"UTF8")
);


is it worth it?
Re: change xml encoding
Reply #3 - Oct 11th, 2005, 8:35pm
 
Since I'm using nanoxml passing lines got from loadStrings(), Toxi suggested to me to use directly the parseFromReader() method of nano. And of course it works Smiley

I put:
Code:
xml.parseFromReader(new InputStreamReader(openStream("http://...../file.xml"),"UTF-8")); 



Thanks to Toxi for the important help!


chr
Re: change xml encoding
Reply #4 - Oct 11th, 2005, 9:19pm
 
toxi wrote on Oct 11th, 2005, 6:56pm:
so i figured out this problem has actually to do with the fact loadStrings() doesn't specify a decoder for its InputStreamReader() instance... This is potentially an obstacle for international users, so maybe we could have an overloaded version of loadStrings(), in which one can specify a character encoding format explicitly like:

loadStrings("hello.xml","UTF8"); or
loadStrings("hello.xml","8859_1");

interesting.. for intl users it uses the default encoding of the client system, though that's probably not a good way to go for most cases. i guess it's not too much of an api change..
Page Index Toggle Pages: 1