Cyrillic alphabet in Multibyte

爷,独闯天下 提交于 2019-12-24 13:28:37

问题


I am pretty new to working with C++. I have an MFC project which needs be translated in to Russian.

If I change the MFC settings to Unicode it shows correctly. My question is:

Is it possible to print cyrillic alphabet with Multibyte? If so, how?

Thanks guys!


回答1:


I encourage you to build your MFC application using Unicode (to be more precise: UTF-16 in MFC/Visual Studio settings), as you wrote "If I change MFC to Unicode it shows correctly.".

At the same time, you can still use another encoding like e.g. UTF-8 for your Cyrillic text, and store this in CStringA or std::string objects. Then, you can convert between UTF-8 and UTF-16 at the "MFC boundaries", e.g. when showing your text on your dialog boxes or other application windows.

You can use some ATL/MFC conversion helpers, or write your own conversion code invoking Windows APIs like MultiByteToWideChar and WideCharToMultiByte, specifying the proper "code page" for the conversion (e.g. CP_UTF8 for UTF-8-encoded text).

You may find this MSDN article on Unicode encoding conversions helpful as well.

On the other hand, if you want to use a specific code page (e.g. 1251 Windows Cyrillic) instead of UTF-8, then you can still use MultiByteToWideChar to convert text from your code page to Unicode UTF-16, specifying the proper code page identifier.



来源:https://stackoverflow.com/questions/48558810/cyrillic-alphabet-in-multibyte

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