XML writer doesn't write correctly

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
D.Cent
Posts: 18
Joined: Sun May 13, 2007 8:12 pm
Location: Schwieberdingen (Germany)
Contact:

XML writer doesn't write correctly

Post by D.Cent »

Ok, so this is a line I have in an XML-file. Reading it out doesn't cause any problems:

Code: Select all

<option type="3" name="resolution" values="640x480@24;1024x768@24;1280x720@24;1280x800@24;1280x1024@24;1920x1080@24;">1920x1080@24</option>
The attribute "values" is used to fill a combobox. After choosing a new resolution in the combobox and pressing on the saving button, I call this code:

Code: Select all

wchar_t* tmp = new wchar_t[len+1];
wcscpy(tmp, str2wchar_t(values));
							
printf("output: %S\n", tmp);
					
xml2->writeElement(L"option", false, L"type", L"3", L"name", str2wchar_t(descriptions[count].c_str()), L"values", str2wchar_t(values));
						
delete[] tmp;
The output of "printf" is fine: 640x480@24;1024x768@24;1280x720@24;1280x800@24;1280x1024@24;1920x1080@24;

The problem is, that writeElement() doesn't write anything in there for the attributes. This is the line it constructs:

Code: Select all

<option type="3" name="resolution" values="">1920x1080@24</option>
If I don't copy the string and use str2wchar_t(values) directly, I see like ~500 binary signs in my file which cannot be read by Irrlicht's XML reader.

Can anyone help?

EDIT: I use Irrlicht 1.7.1 on OpenSuSE Linux 11.2 with a NVidia card (OpenGL 3.2).
EDIT2: This is the function str2wchar_t():

Code: Select all

const wchar_t *str2wchar_t(std::string str)
{
    size_t needed = ::mbstowcs(NULL,&str[0],str.length());
    wstring output;
    output.resize(needed);
    ::mbstowcs(&output[0],&str[0],str.length());
    const wchar_t *pout = output.c_str();
    return pout;
}
Post Reply