16inline std::string win_to_utf(
const WCHAR * s,
int wlen = -1 )
18 auto len = WideCharToMultiByte( CP_UTF8, 0, s, wlen,
nullptr, 0,
nullptr,
nullptr );
21 std::ostringstream ss;
22 ss <<
"WideCharToMultiByte(...) returned 0 and GetLastError() is " << GetLastError();
23 throw std::runtime_error( ss.str() );
27 buffer.resize( len - 1 );
28 len = WideCharToMultiByte( CP_UTF8, 0, s, wlen, &buffer[0], len,
nullptr,
nullptr );
31 std::ostringstream ss;
32 ss <<
"WideCharToMultiByte(...) returned 0 and GetLastError() is " << GetLastError();
33 throw std::runtime_error( ss.str() );
40inline std::string win_to_utf( std::wstring
const & s )
42 return win_to_utf( s.c_str(), (
int) s.length() );
Definition: stabilized-value.h:12