Page 1 of 1

convert CEGUI::String to a char array[] or char*

Posted: Wed Apr 27, 2005 03:44
by Aussie1497
Hi,

I need to grab input from my edit box and set a variable based on that. I have the following in my code:

CEGUI::String ipaddress = ek->window->getText();

I'd like to set ipaddress to either a char* or a char array. How do I accomplish this?

IE: char * ipaddress = ek->window->getText() gives me an error because it's not of type CEGUI::String.

Thanks!

Re: convert CEGUI::String to a char array[] or char*

Posted: Wed Apr 27, 2005 10:22
by daesdemon
To have the const char * of a String, i think you can use:

const char* String::c_str();

So ek->window->getText().c_str() can be useful to get it ;)

Posted: Fri Feb 24, 2006 13:40
by Pacome
This method only works for CEGUI::String without accents.
It doesn't work with words containing accents, like "hôtel" in french.

You can see the details here with a small source code to test it : http://www.cegui.org.uk/phpBB2/viewtopic.php?t=1206

Regards,

Pacôme