Page 1 of 1

String Constructor

Posted: Wed Aug 06, 2008 21:52
by Kevin
Hello,

So there seems to be something a little strange going on with the String constructor

Code: Select all

CEGUI::String(const char* chars, CEGUI::String::size_type chars_len);


I've tried a few small tests, and it seems to work as expected. However, when I pass it a 32 character string (of unsigned chars) full of character 10001000, I get back the 16 character string:

Code: Select all

11000011 10001000 11000010 10001000 11000011 10001000 11000010 10001000 11000011 10001000
11000010 10001000 11000011 10001000 11000010 10001000


A few similar tests suggest that the problem is something to do with the original string containing negative value characters, but I'm not sure if that's the problem exactly.

Posted: Thu Aug 07, 2008 09:22
by CrazyEddie
Hi,

Thanks for the report. I'll have a look :)

CE.

Posted: Mon Aug 11, 2008 23:53
by Kevin
Hello,

As a follow-up, it seems there is a similar problem (or perhaps the same problem?) with the c_str() function.

Code: Select all

CEGUI::String str(32, ' ');
for (CEGUI::String::size_type i = 0; i < 32; i++)
{
  str[i] = 0xff;
}
const char* ch = str.c_str();


After executing, str has length 32, but ch has 64 characters before the null - 32 of each 0xc3 and 0xbf (alternating).

Then executing a similar loop:

Code: Select all

for (CEGUI::String::size_type i = 0; i < 32; i++)
{
  char ch2 = str[i];
}


works as expected - after each iteration ch2 is 0xff.