Win32 API函数需要什么编码? [英] What encoding Win32 API functions expect?

查看:97
本文介绍了Win32 API函数需要什么编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,MessageBox函数具有用于文本和标题的LPCTSTR类型参数,它分别指定_UNICODE或_MBCS时指向char或指向wchar的指针。



MessageBox功能如何解释这些蜇?作为哪个编码?



只能解释我设法找到的是:



http://msdn.microsoft.com/en-us/library/cwe8bzh0(VS.90 ).aspx



但是它没有说任何关于编码的东西?只要在_MBCS的情况下,一个字符占用一个wchar(在Windows上为16位),在_UNICODE为一个或两个char(8位)的情况下。



<那么那些一些微软的UTF-8和UTF-16的版本呢就忽略了在UTF-8的情况下必须用3或4个字节进行编码的东西,而在UTF- 16?有没有办法在MessageBox的基础多语言平面上显示任何东西?

解决方案

通常有两种不同的实现每个功能:




  • MessageBoxA ,它接受ANSI字符串

  • MessageBoxW ,它接受Unicode字符串



是指当前分配给该进程的多字节代码页。这根据用户的偏好和区域设置而有所不同,尽管Win32 API函数(例如 WideCharToMultiByte )可以被视为正确的转换,而 GetACP 函数将告诉您正在使用的代码页。 MSDN解释了ANSI代码页以及它如何与Unicode交互。

'Unicode'通常表示UCS-2;也就是支持0xFFFF以上的字符不一致。我还没有尝试过,但是最近版本(> Windows 2000)中的UI函数,如 MessageBox 应该支持BMP之外的字符。


For example, MessageBox function has LPCTSTR typed argument for text and caption, which is a pointer to char or pointer to wchar when _UNICODE or _MBCS are defined, respectively.

How does the MessageBox function interpret those stings? As which encoding?

Only explanation I managed to find is this:

http://msdn.microsoft.com/en-us/library/cwe8bzh0(VS.90).aspx

But it doesn't say anything about encoding? Just that in case of _MBCS one character takes up one wchar (which is 16-bit on Windows) and that in case of _UNICODE one or two char's (8-bit).

So are those some Microsoft's versions of UTF-8 and UTF-16 that ignore anything that has to be encoded in 3 or four bytes in case of UTF-8 and anything that has to be encoded in 4 bytes in case of UTF-16? And is there a way to show anything outside of basic multilingual plane of Unicode with MessageBox?

解决方案

There are normally two different implementations of each function:

  • MessageBoxA, which accepts ANSI strings
  • MessageBoxW, which accepts Unicode strings

Here, 'ANSI' means the multi-byte code page currently assigned to the process. This varies according to the user's preferences and locale setting, although Win32 API functions such as WideCharToMultiByte can be counted on to do the right conversion, and the GetACP function will tell you the code page in use. MSDN explains the ANSI code page and how it interacts with Unicode.

'Unicode' generally means UCS-2; that is, support for characters above 0xFFFF isn't consistent. I haven't tried this, but UI functions such as MessageBox in recent versions (> Windows 2000) should support characters outside the BMP.

这篇关于Win32 API函数需要什么编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆