0

I'm trying to convert wstring to string and tried the below code:

std::wstring_convert<std::codecvt_utf16<wchar_t>, wchar_t> utf8convertor;
std::string str = utf8convertor.to_bytes(utf16str);

My input is "Doc 01". But I get the output as " D o c 0 1".

Any help on what I'm doing wrongly

zak
  • 310
  • 3
  • 19

1 Answers1

0

This SO answer here helped me.

And here's the code I arrived at:

std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> convert;
std::string str = convert.to_bytes(utf16str);
zak
  • 310
  • 3
  • 19