I want to get 2 functions so i can interface my stuff with irrlicht's wide needs. I dont care about the need for foreign chars so only want to use normal ascii strings throughout my project.
Is this code 'safe' ? or should i be 'delete'ing wc_out?
///StrToWide
irr::core::stringw StrToWide(const std::string & str)
{
const char*st=str.c_str();
irr::core::stringw out=L"";
// Convert to a wchar_t*
size_t alloc_len = strlen(st) + 1;
wchar_t* wc_out = new wchar_t[alloc_len];
mbstowcs(wc_out, st, alloc_len);
out += wc_out;
return out;
}
///StrFromWide
std::string StrToWide(const irr::core::stringw & str)
{
//any help here will be appreciated also.
}