Converting char to wchar_t.

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Converting char to wchar_t.

Post by disanti »

Yes, I have Googled and Searched the forum for this. :roll:

I am reading a title from a file into a character array and now I want to set the window title but I can't... My current code puts a "??????????????????#0.02" into the caption:

wchar_t wtitle[128];
swprintf(wtitle, 128, L"%s%s", title, PSS4_VERSION);

If someone can please explain to me how to convert the character array title into a wide character array, that would be great! Thanks~ John DiSanti

Forgot to say: I did debug it and it is loading the text from the file flawlessly, the swprintf is the problem.
________
Growing Marijuana
Last edited by disanti on Tue Feb 22, 2011 8:09 am, edited 1 time in total.
Guest

Post by Guest »

I think swprintf expects string arguments to be wide as well.

Search the http://www.gamedev.net forums. There's almost certainly something there.
thesmileman
Posts: 360
Joined: Tue Feb 10, 2004 2:20 am
Location: Lubbock, TX

Post by thesmileman »

The first search in google for "C++ converting char to wchar_t" pulls up several usuaful sites about using the wctob() function

here is one of them:

http://www.mkssoftware.com/docs/man3/wctob.3.asp
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Post by disanti »

@thesmileman: That function is to convert a single byte wchar_t into a char... That is completely useless for my needs but thanks for looking! ;)
________
Knee Problems Advice
Last edited by disanti on Tue Feb 22, 2011 8:09 am, edited 1 time in total.
joy
Posts: 124
Joined: Tue Apr 27, 2004 9:15 am
Location: Germany

Post by joy »

what about this one:

_mbstowcsz(wchar_t* wcstr, const char* mbstr, size_t count);
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Post by disanti »

That function appears to be Windows only, this is a Windows and Linux game.
________
Free gift cards
Last edited by disanti on Thu Feb 24, 2011 10:26 am, edited 1 time in total.
mm765
Posts: 172
Joined: Fri May 28, 2004 10:12 am

Post by mm765 »

mbstowcs
or
irr::core::stringw tmp(char *);
tmp.c_str();
Post Reply