XMLWriter and Big-Endian

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
kschn
Posts: 13
Joined: Sat Jul 01, 2006 1:16 pm
Location: Vandoeuvre (France)

XMLWriter and Big-Endian

Post by kschn »

I'm developping a video game with irrlicht which aims to be cross platform.

Up until now this was going smoothly thanks to irrlicht philosophy ... I had same results on both windows and mac os X.

I then wanted to use xml for serialization/deserialization purposes. It works really fine on windows, unix ... etc working on x86 but the xml generated by irrlicht xmlWriter is unreadable on mac os X.

It looks like this :
http://kschn.free.fr/Docs/Image%201.png

There's some weird characters ... and there's also a lot of characters missing from what the file should be. Textmate (the notepad screen you see) is able to open utf-8 utf-16 big endian and little endian, but I tested all those modes and the file is still unreadable. So It may be a writer problem ...

I believe this is because my machine is a ppc and so is a big-endian not a little-endian like the x86 are.

Is the xmlWriter trully not big-endian compatible or am I missing the point here ?
Is there a simple way to solve this problem ?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The XML implementation claims to be compatible with UTF variants etc, but what it really does is to write the two first bytes to the file assuming this is UTF-16. So it completely trashes all your output (because the first two bytes is no good choice on OSX which uses 32bit wchar_t and the better byte ordering :wink: )
So basically the XML implementation is not working on big endian systems and could easily break on all Linux/Unix systems for non-ASCII characters. However, Irrlicht does not handle those chars correctly in other situations, too, so nothing lost there (but much to improve)
I have an untested fix to make the Linux/Unix versions use UTF-32 which could also help for your problems because with the correct header the endianess should be correctly recognized. I'll post the patch when I'm home so you could try it on your own.
kschn
Posts: 13
Joined: Sat Jul 01, 2006 1:16 pm
Location: Vandoeuvre (France)

Post by kschn »

Thanks a lot for the quick reply. Looking forward the fix :)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

kschn
Posts: 13
Joined: Sat Jul 01, 2006 1:16 pm
Location: Vandoeuvre (France)

Post by kschn »

It works :)

Thanks a looooooooot you're a lifesaver hybrid, and thanks the whole community for this wonderfull engine :p

Is there any plans for including this patch on next irrlicht releases ?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Hmm, since it works now it has good chances :D Do you have a small example which I could also use under windows and Linux to test the new code?!
kschn
Posts: 13
Joined: Sat Jul 01, 2006 1:16 pm
Location: Vandoeuvre (France)

Post by kschn »

Hum, not really but as I was planning to make a little tutorial on how using xml with irrlicht I think I can write a little something.

I'll post this in a couple of days. Anyway thanks again for this patch ;)
Post Reply