What is the Linux equivalent of: MultiByteToWideChar & WideCharToMultiByte?

NSA picture NSA · Jul 18, 2010 · Viewed 14.6k times · Source

I am working with a class that wraps the std::wstring, this code needs to be cross platform, are there equivalents to the windows functions: MultiByteToWideChar & WideCharToMultiByte on linux?

Thank you.

Answer

Philipp picture Philipp · Jul 18, 2010

The Linux equivalents are the iconv functions iconv_open, iconv and iconv_close (say man 3 iconv_open etc. for the documentation). For cross-platform applications, use dedicated libraries such as ICU instead. Such libraries already contain their own string classes; there is no need to wrap std::wstring.