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.
Converting Question
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
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
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
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.
hm
Code: Select all
Error 1 error C2664: 'irr::gui::IGUIFont::draw' : cannot convert parameter 1 from 'irr::core::stringw' to 'const wchar_t *'
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.