String Constructor

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

User avatar
Kevin
Not too shy to talk
Not too shy to talk
Posts: 29
Joined: Mon May 26, 2008 15:44

String Constructor

Postby Kevin » Wed Aug 06, 2008 21:52

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.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Thu Aug 07, 2008 09:22

Hi,

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

CE.

User avatar
Kevin
Not too shy to talk
Not too shy to talk
Posts: 29
Joined: Mon May 26, 2008 15:44

Postby Kevin » Mon Aug 11, 2008 23:53

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.


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 5 guests