为什么同时使用 UNICODE 和 _UNICODE? [英] Why both UNICODE and _UNICODE?

查看:41
本文介绍了为什么同时使用 UNICODE 和 _UNICODE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在查看 Visual Studio 生成的命令行,对于我的一个项目,它定义了两个符号:_UNICODEUNICODE.现在,如果我理解这个文档这个相当古老的文档,_UNICODE 符号是 VC++ 的东西,它导致某些标准函数在它们的接口中使用 wchar_t 而不是 char.

I've been looking at the command line generated by Visual Studio, and for one of my project it defines two symbols: _UNICODE and UNICODE. Now if I understand this document this rather old document, the _UNICODE symbol is a VC++ thing that causes certain standard functions to use wchar_t instead of char in their interfaces.

但是没有下划线的 UNICODE 是什么意思?

But what does the UNICODE without an underscore mean?

推荐答案

Raymond Chen 在这里解释:TEXT 与 _TEXT 与 _T,以及 UNICODE 与 _UNICODE:

Raymond Chen explains it here: TEXT vs. _TEXT vs. _T, and UNICODE vs. _UNICODE:

不带下划线的普通版本会影响 Windows 头文件视为默认的字符集.因此,例如,如果您定义 UNICODE,则 GetWindowText 将映射到 GetWindowTextW 而不是 GetWindowTextA.类似地,TEXT 宏将映射到 L"..." 而不是 "...".

The plain versions without the underscore affect the character set the Windows header files treat as default. So if you define UNICODE, then GetWindowText will map to GetWindowTextW instead of GetWindowTextA, for example. Similarly, the TEXT macro will map to L"..." instead of "...".

带有下划线的版本会影响 C 运行时头文件视为默认的字符集.例如,如果您定义 _UNICODE,则 _tcslen 将映射到 wcslen 而不是 strlen.类似地,_TEXT 宏将映射到 L"..." 而不是 "...".

The versions with the underscore affect the character set the C runtime header files treat as default. So if you define _UNICODE, then _tcslen will map to wcslen instead of strlen, for example. Similarly, the _TEXT macro will map to L"..." instead of "...".

查看 Windows SDK,您会发现如下内容:

Looking into Windows SDK you will find things like this:

#ifdef _UNICODE
#ifndef UNICODE
#define UNICODE
#endif
#endif

这篇关于为什么同时使用 UNICODE 和 _UNICODE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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