How to deal with Unicode strings in C/C++ in a cross-platform friendly way?

微笑、不失礼 提交于 2019-11-30 19:47:37

I can only suggest you to check this library out: http://cppcms.sourceforge.net/boost_locale/docs/
It might help, it's a boost candidate for now but I believe it will make it.

Artyom

If you writing portable code:

1st Never use wchar_t it is nor portable and its encoding is not well defined between platforms (utf-16 windows/utf-32 all others).

Never use TChar, use plain std::string encoded as UTF-8.

When dealing with Brain Damaged Win32 API just convert UTF-8 string to UTF-16 before calling it.

See https://stackoverflow.com/questions/1049947/should-utf-16-be-considered-harmful as well about how Windows project adopt UTF-8 as main encoding.

You can keep all your strings UTF-8 encoded and just convert them to UTF-16 before interacting with WIn32 API. Take a look at UTF8-CPP library for some easy to use conversion functions

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