Something doesn't work with XML encoding

Just starting out? Need help? Post your questions and find answers here.
rkonopin
New User
New User
Posts: 4
Joined: Sun Dec 22, 2013 5:55 am
Location: Warsaw, Poland

Something doesn't work with XML encoding

Post 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...
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Something doesn't work with XML encoding

Post 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
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
rkonopin
New User
New User
Posts: 4
Joined: Sun Dec 22, 2013 5:55 am
Location: Warsaw, Poland

Re: Something doesn't work with XML encoding

Post 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! :)
Post Reply