const wchar_t* to a char array
const wchar_t* to a char array
How would I go about converting a const wchar_t * variable to a character array?
Code: Select all
c8* convertTochar(const wchar_t* w)
{
size_t count = 255;
c8* c = (char*)malloc( 255 );
wcstombs(c, w, count);
return c;
}
another way would be to use the built in string functions with irrlicht.
wchar_t -> character array
character array -> wchar_t
wchar_t -> character array
Code: Select all
irr::core::string <char> converter;
converter = some_wide_char;
converter.c_str();
Code: Select all
irr::core::string <wchar_t> converter;
converter = some_char_array;
converter.c_str();
Confined is a 3D Action RPG Game in development. http://confined.coderzilla.net
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=29130
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=29130
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
That works for the usual ASCII set only, though, or at least is highly unportable. It's used in several examples, though, and is fine for most simple things. I think I'll have to add some partial template specialization to handle this in a clean way. Just need to make this compile on all platforms somehow...