How to convert stringc to stringw ?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Chmel_Tolstiy
Posts: 41
Joined: Mon Feb 11, 2008 3:06 pm

How to convert stringc to stringw ?

Post by Chmel_Tolstiy »

[-]
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I'd say pretty good as long as you keep the character set small.
konrad
Posts: 15
Joined: Wed Oct 03, 2007 7:07 pm
Location: Poland

Post 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();
}
Chmel_Tolstiy
Posts: 41
Joined: Mon Feb 11, 2008 3:06 pm

Post by Chmel_Tolstiy »

thanks to all
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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).
chronos1981
Posts: 8
Joined: Wed Mar 19, 2008 12:03 pm

Post 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.
Post Reply