多字节西里尔字母表
Cyrillic alphabet in Multibyte
我对使用 C++ 还很陌生。我有一个 MFC 项目需要翻译成俄语。
如果我将 MFC 设置更改为 Unicode,它会正确显示。我的问题是:
是否可以使用多字节打印西里尔字母?如果是,怎么做?
谢谢大家!
我鼓励您使用 Unicode 构建 MFC 应用程序(更准确地说:MFC/Visual Studio 设置中的 UTF-16),正如您所写的 "If I change MFC to Unicode it shows correctly.".
同时,您仍然可以使用其他编码,例如UTF-8 用于您的西里尔文字,并将其存储在 CStringA
或 std::string
对象中。然后,您可以在 "MFC boundaries" 处在 UTF-8 和 UTF-16 之间进行转换,例如在对话框或其他应用程序上显示文本时 windows。
您可以使用一些 ATL/MFC conversion helpers,或编写您自己的转换代码调用 Windows API,如 MultiByteToWideChar
和 WideCharToMultiByte
,指定正确的 "code page"转换(例如 CP_UTF8
用于 UTF-8 编码的文本)。
您可能会发现 this MSDN article on Unicode encoding conversions 也有帮助。
另一方面,如果您想使用特定的代码页(例如 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。
我对使用 C++ 还很陌生。我有一个 MFC 项目需要翻译成俄语。
如果我将 MFC 设置更改为 Unicode,它会正确显示。我的问题是:
是否可以使用多字节打印西里尔字母?如果是,怎么做?
谢谢大家!
我鼓励您使用 Unicode 构建 MFC 应用程序(更准确地说:MFC/Visual Studio 设置中的 UTF-16),正如您所写的 "If I change MFC to Unicode it shows correctly.".
同时,您仍然可以使用其他编码,例如UTF-8 用于您的西里尔文字,并将其存储在 CStringA
或 std::string
对象中。然后,您可以在 "MFC boundaries" 处在 UTF-8 和 UTF-16 之间进行转换,例如在对话框或其他应用程序上显示文本时 windows。
您可以使用一些 ATL/MFC conversion helpers,或编写您自己的转换代码调用 Windows API,如 MultiByteToWideChar
和 WideCharToMultiByte
,指定正确的 "code page"转换(例如 CP_UTF8
用于 UTF-8 编码的文本)。
您可能会发现 this MSDN article on Unicode encoding conversions 也有帮助。
另一方面,如果您想使用特定的代码页(例如 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。