Page 1 of 1

Something doesn't work with XML encoding

Posted: Tue Sep 16, 2014 11:09 pm
by rkonopin
This code should "copy" files (with minor changes, maybe - spaces, EOLs etc). Instead, it changes the way the Polish characters are represented:



GPX=LoadXML(#PB_Any,"GPSdata_in.gpx",#PB_UTF8)
SaveXML(GPX,"GPSdata_out.gpx")



Of course the file GPSdata_in.gpx is a valid XML document (created by the GPS unit or GPS software) with the UTF-8 encoding. 2 GPS devices and at least 3 different programs (English language ones) understand those Polish characters correctly.

I have found one way to keep them intact: Load the XML as it was in #PB_Ascii encoding. But after saving it changes the XML header (to "ISO-8859-1"), thus the GPS device reads such a file misinterpreting characters...If you manually change the XML header in the file created this way back to "UTF-8", everything is OK.

Same messy problems with the creation of XML (CreateXML(...) command). Polish characters from the text fields are encoded the wrong way.

And additionally, to make things even worse, the text fields read from the XML are displayed the wrong way on the screen (always, both when the XML was loaded as UTF-8 as well as Ascii)

Something is wrong here the very strange way...

Re: Something doesn't work with XML encoding

Posted: Wed Sep 17, 2014 12:50 am
by IdeasVacuum
I have no idea what the cause of the issue is, but make sure:
1) Use PB5.30
2) Compiler/Compiler Options/Create Unicode executable
3) File/Preferences/Compiler/Defaults/Source file Text encoding: UTF-8

Re: Something doesn't work with XML encoding

Posted: Wed Sep 17, 2014 7:45 am
by rkonopin
Thanks a lot! I have previously tried checking option "unicode executable" in the compiler preferences, with no success. But haven't tried those File/preferences settings. Checked UTF-8 and unicode executable ("second instance" here) and everything now is perfectly fine! :)