wchar_t is evil... it keeps killing my char*'s

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
cyanide
Posts: 13
Joined: Sat Sep 03, 2005 9:39 pm

wchar_t is evil... it keeps killing my char*'s

Post by cyanide »

i can't just use a typecast to get my char*'s converted to wchar_t*'s. that produces random characters. i can't seem to find any function to convert it properly either. can anyone help me?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Yes, it's a big problem...
I do it this way:

Code: Select all

  wchar_t wc[100];
  char c[100];
  for(int t = 0; wc[t] != '\0'; t++)
    c[t] = (unsigned char)wc[t];

  for(int t = 0; c[t] != '\0'; t++)
    wc[t] = c[t];
I also did not find another solution to this... :?
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
cyanide
Posts: 13
Joined: Sat Sep 03, 2005 9:39 pm

Post by cyanide »

thanks. as long as it works, i guess.
hybrid

Post by hybrid »

Try functions such as mbstowcs. Otherwise you'll get into trouble with real multibyte chars. And it's much more efficient...
Post Reply