I was wondering is it safe to do so?
wchar_t wide = /* something */; assert(wide >= 0 && wide < 256 &&); char myChar = static_cast<char>(wide);
If I am pretty sure the wide char will fall within ASCII range.
Why not just use a library routine wcstombs.
wcstombs
2.1m questions
2.1m answers
60 comments
57.0k users