Page 1 of 1

How to convert stringc to stringw ?

Posted: Mon Feb 11, 2008 3:08 pm
by Chmel_Tolstiy
[-]

Posted: Mon Feb 11, 2008 4:06 pm
by hybrid
I'd say pretty good as long as you keep the character set small.

Posted: Mon Feb 11, 2008 4:32 pm
by konrad
You must use c_str() function to exporting stringc to stringw or stringw to stringc...
Example:

Code: Select all

#include <irrlicht.h>
#include <iostream>
using namespace irr;
#pragma comment(lib,"irrlicht.lib")

int main()
{
   core::stringw str2=L"TEST";
   core::stringc str;
   str=str2.c_str();
   std::cout<<str.c_str();
}

Posted: Mon Feb 11, 2008 7:13 pm
by Chmel_Tolstiy
thanks to all

Posted: Mon Feb 11, 2008 8:42 pm
by hybrid
You coul have helped yourself pretty easily by using the search button. That's why I replied only with my warning, which you should take into considerations, though. Because you cannot rely on proper transformation of characters outside the basic ASCII set using this method. All other characters require calls to basic C functions which the search should also come up with, Acki often posts about these methods).

Posted: Wed Dec 23, 2009 12:46 pm
by chronos1981
it finally makes sense thanks!

I'm working on a game, taking baby steps of course right now just working on the chat box. I could not get the text to show from the client to the server and when I finally got the irrnetbeta stuff working, it would crash the server when i sent the wrong kind of string.