const wchar_t* to a char array
Posted: Tue Jul 29, 2008 3:49 am
How would I go about converting a const wchar_t * variable to a character array?
Official forum of the Irrlicht Engine
https://irrlicht.sourceforge.io/forum/
Code: Select all
c8* convertTochar(const wchar_t* w)
{
size_t count = 255;
c8* c = (char*)malloc( 255 );
wcstombs(c, w, count);
return c;
}
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();