Converting Question

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
combine
Posts: 4
Joined: Thu Mar 15, 2007 6:23 pm

Converting Question

Post by combine »

Hi @All

I want to make me helper classes for Irrlicht.
But i have problems to convert a string to wchar_t

extern "C" __declspec(dllexport) void __stdcall ShowText(string test,int SH_X,int SH_Y)
{
font->draw(test,
core::rect<s32>(SH_X,SH_Y,0,0),
video::SColor(255,255,255,255));

}

I want convert the string "test" to wchar_t, can everyone say me how i can do this?

thx for help.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

You didn't say what type "string" is. I'm assuming a std::string (i.e. std::basic_string<char>). Irrlicht provides a very basic char -> wchar_t conversion function (please ignore (or correct!) the incorrect comment about it being a "Unicode" conversion, and the arguments not matching the order implied by the function name).

Code: Select all

#include "irrString.h"

irr::core::stringw wideString;

stringc_to_stringw(wideString, test.c_str());

font->draw(wideString, ...
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
combine
Posts: 4
Joined: Thu Mar 15, 2007 6:23 pm

Post by combine »

Hi,
Thx for fast answer.
Yes i´m using for the string std::string, but my compiler doesnt find the command "stringc_to_stringw"
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

I think it's sufficient with just

Code: Select all

stringw StringEmil=originalstring.c_str()
If you don't have anything nice to say, don't say anything at all.
combine
Posts: 4
Joined: Thu Mar 15, 2007 6:23 pm

Post by combine »

hm :(

Code: Select all

Error	1	error C2664: 'irr::gui::IGUIFont::draw' : cannot convert parameter 1 from 'irr::core::stringw' to 'const wchar_t *'	
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

Then do like this

Code: Select all

font->draw(StringEmil.c_str(),
core::rect<s32>(SH_X,SH_Y,0,0),
video::SColor(255,255,255,255)); 
If you don't have anything nice to say, don't say anything at all.
Post Reply