What is the Linux equivalent of: MultiByteToWideChar & WideCharToMultiByte?

ε祈祈猫儿з 提交于 2019-12-20 10:29:30

问题


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.


回答1:


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.




回答2:


mbtowc and wctomb are the most direct equivalents, but note that they operate on the multibyte character set corresponding to the current LC_CTYPE locale (which can be changed with setlocale()).



来源:https://stackoverflow.com/questions/3277013/what-is-the-linux-equivalent-of-multibytetowidechar-widechartomultibyte

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!