这个问题在这里已经有了答案:
Visual Studio Character Sets 'Not set' vs 'Multi byte character set'
(2 个回答)
8 年前关闭。
这可能是一个基本问题,但由于某些原因我不太明白。
问题是:"Character Set"
究竟是什么? Visual Studio 中的属性是?
(例如,您可以设置为: Use Unicode Character Set
、 Use Multi-Byte Character Set
、 Not Set
- 在属性中)
我或多或少知道什么是 Unicode,但为什么我们需要设置这个属性?
例如,如果我不设置它并使用 L"hello"
项目中的字符串类型,它没有意义吗?
最佳答案
设置 Character Set
Visual Studio 中的选项将为您定义一些预处理器符号:
Unicode
将定义 _UNICODE
Use Multi-byte Character Set
将定义 _MBCS
Not Set
不会定义任何这些。 现在,如果你查看 SDK 中的一些头文件,你会看到一堆这样的:
#ifdef _UNICODE
#define GetDeltaInfo GetDeltaInfoW
#else
#define GetDeltaInfo GetDeltaInfoA
#endif /* _UNICODE */
其中 W 和 A 函数是:
BOOL
WINAPI
GetDeltaInfoA(
__in LPCSTR lpDeltaName,
__out LPDELTA_HEADER_INFO lpHeaderInfo
);
/**
* Gets header information for a delta accessed by Unicode file name.
* @param lpDeltaName Delta file name, Unicode.
* @param lpHeaderInfo Header information for given Delta.
* @return TRUE if success, FALSE otherwise.
*/
BOOL
WINAPI
GetDeltaInfoW(
__in LPCWSTR lpDeltaName,
__out LPDELTA_HEADER_INFO lpHeaderInfo
);
因此,通过设置 Unicode 或多字节,您将选择正确的函数集。
关于c++ - Visual Studio 中的字符集是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18959551/