This is bloody annoying. My biggest annoyance with this engine is the strings!
Current dilema: How can i convert a stringc or stringw to a c8?
strings!!
-
- Posts: 22
- Joined: Thu Aug 23, 2007 12:39 pm
Yea, thanks for that, but .c_str() gives me the problem ofloki1985 wrote:both stringc and stringw have a c_str() method, just like regular c++ strings... read the documentation next time.
I did actually read the manual first but i didn't understand, that's why i posted it on the forum. Isn't that what forums are for?cannot convert parameter 1 from 'const wchar_t *' to 'irr::c8 *'
its not really what you're asking, but maybe it works...
Code: Select all
core::stringw test = "test";
core::string<wchar_t> test2 = test.c_str();
core::string<char> test3 = test.c_str();
Last edited by zillion42 on Fri Feb 06, 2009 8:30 pm, edited 1 time in total.
I had the same problems, comming from a b3d, bmax, c#, php background i completely agree c/c++ string handllings a mess,
so do what i did, Create your own wrappers for strings. You can quite easily implement high level methods like Replace, Mid, Trim etc.
then you can use ".c_str" for quickly convertig it to an array.
basically keep everything as a "string" in your prog, and write your own conversion functions just once for using with irrlicht etc...
so do what i did, Create your own wrappers for strings. You can quite easily implement high level methods like Replace, Mid, Trim etc.
then you can use ".c_str" for quickly convertig it to an array.
basically keep everything as a "string" in your prog, and write your own conversion functions just once for using with irrlicht etc...
Last edited by dgrafix on Mon Feb 09, 2009 1:43 pm, edited 4 times in total.
C++/Irrlicht Noob pl3se B p4t1ent.
Visit www.d-grafix.com
Visit www.d-grafix.com
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
OK, if you call c_str() on a stringw, you'll get a wchar_t array out of it.interceptor wrote: Yea, thanks for that, but .c_str() gives me the problem ofcannot convert parameter 1 from 'const wchar_t *' to 'irr::c8 *'
If you want a c8 array, then you'll have to convert the content of the wide string. If you're OK with the contents as ASCII/Latin-1 (rather than utf-8), then Irrlicht can do this for you, just by creating a narrow string from the wide string.
Code: Select all
stringw wide(L"content");
stringc narrow(wide);
const c8* narrowContent = narrow.c_str();
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
- Posts: 22
- Joined: Thu Aug 23, 2007 12:39 pm