XML bug

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.
evo
Posts: 96
Joined: Mon Jun 27, 2005 6:46 pm
Location: The Netherlands

Post by evo »

I assume you generating your xml file with some C code, using the fprintf command. Correct ?

If so adding then \n at the end of the line ought to work. It is probably a compiler option that causes the incorrect line ends.

To circumvent the problem you can add proper line ends this way (this is instead of \n):
Windows: \x0D\x0A
Unix: \x0A
Macintosh: \x0D

What this does is add one or two characters. It is just spelled out in hexadecimal. x0D = 13 decimal = Carriage Return and x0A = 10 decimal = Line Feed
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

This is from CXMLWriter.cpp

Code: Select all

//! Writes a line break
void CXMLWriter::writeLineBreak()
{
	if (!File)
		return;

	File->write("\n", 2);
}

And this is from my writer to string class

Code: Select all

//! Writes a line break
void CXMLWriterToString::writeLineBreak() 
{
	str += "\n";
}
I think I can make this work lend a hand if you can please and thanks.
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

evo wrote:I assume you generating your xml file with some C code, using the fprintf command. Correct ?

If so adding then \n at the end of the line ought to work. It is probably a compiler option that causes the incorrect line ends.

To circumvent the problem you can add proper line ends this way (this is instead of \n):
Windows: \x0D\x0A
Unix: \x0A
Macintosh: \x0D

What this does is add one or two characters. It is just spelled out in hexadecimal. x0D = 13 decimal = Carriage Return and x0A = 10 decimal = Line Feed
Brilliant I "Think" it's working but there is no way to tell until I write to a file to see if it actually breaks the line.

I'll get back on that.
evo
Posts: 96
Joined: Mon Jun 27, 2005 6:46 pm
Location: The Netherlands

Post by evo »

Ok. I have tried a couple of things and could this be a bug in XMLwriter?

In CXMLWriter.cpp: writeLineBreak sends 2 characters to be written to file.

Code: Select all

//! Writes a line break
void CXMLWriter::writeLineBreak()
{
	if (!File)
		return;

	File->write("\n", 2);
}

File->write issues a normal fwrite in CWriteFile.cpp

When I try this out in DevC / WinXP, this causes an extra zero character to be written to the file after the CR/LF. When I use File->write("\n", 1) everything works perfectly.

To solve the problem I guess you need to change the code of CXMLWriter.cpp. I am not sure if this is a platform independant solution.
Last edited by evo on Wed Aug 10, 2005 10:28 am, edited 1 time in total.
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

I havent actually used the writer yet... I'm using writer to string.

I don't know how to recompile the engine yet.

I have however solved my problem..well sorta.

I'm taking a new direction I'm going to write a simple string class to store the list undo and redo functions for guice.

I'll still use xml for the configuration though or possibly the earlier example
and go without xml all together.

this is much more complicated then it was ment to be and irrlicht has a lot of bugs I think.
evo
Posts: 96
Joined: Mon Jun 27, 2005 6:46 pm
Location: The Netherlands

Post by evo »

Ok. I have tried a couple of things and could this be a bug in XMLwriter ?
MODERATOR please move this post to the BUG Reports Forum
Masdus
Posts: 186
Joined: Tue Aug 26, 2003 1:13 pm
Location: Australia

Post by Masdus »

It would probably be best if you just start a new post in the bug section stating the exact problem so Niko doesn't have to look through multiple messages to get to the problem
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

Masdus wrote:It would probably be best if you just start a new post in the bug section stating the exact problem so Niko doesn't have to look through multiple messages to get to the problem
so your plan is to make a new message??

whatever anyone that is active on the board should know whats where and what not... this isn't a bug report guys it's more of a personal problem.

And it's outlived it's usefulness it may as well be deleted but your "please move" posts just bump it.
Post Reply