_T在CString中代表什么?

时间:2021-11-10 17:17:19

What does the "T" represents in a string. For example _T("Hello").I have seen this in projects where unicode support is needed.What it actually tells the processor

“T”在字符串中表示什么。例如_T(“Hello”)。我在需要unicode支持的项目中看到了这一点。它实际告诉处理器的是什么

3 个解决方案

#1


26  

_T stands for “text”. It will turn your literal into a Unicode wide character literal if and only if you are compiling your sources with Unicode support. See http://msdn.microsoft.com/en-us/library/c426s321.aspx.

_T代表“文字”。当且仅当您使用Unicode支持编译源时,它才会将您的文字转换为Unicode宽字符文字。请参阅http://msdn.microsoft.com/en-us/library/c426s321.aspx。

#2


12  

From MSDN:

来自MSDN:

Use the _T macro to code literal strings generically, so they compile as Unicode strings under Unicode or as ANSI strings (including MBCS) without Unicode

使用_T宏一般编码文字字符串,因此它们在Unicode下编译为Unicode字符串或在没有Unicode的情况下编译为ANSI字符串(包括MBCS)

#3


11  

It's actually used for projects where Unicode and ANSI support is required. It tells the compiler to compile the string literal as either Unicode or ANSI depending on the value of a precompiler define.

它实际上用于需要Unicode和ANSI支持的项目。它告诉编译器将字符串文字编译为Unicode或ANSI,具体取决于预编译器定义的值。

Why you would want to do this is another matter. If you want to support Unicode by itself then just write Unicode, in this case L"Hello". The _T() macro was added when you needed to support Windows NT and later (which support Unicode) and Windows 9x/ME (which do not). These days any code using these macros is obsolete, since all modern Windows versions are Unicode-based.

为什么你想要这样做是另一回事。如果您想单独支持Unicode,那么只需编写Unicode,在本例中为L“Hello”。当您需要支持Windows NT及更高版本(支持Unicode)和Windows 9x / ME(不支持Unicode)时,会添加_T()宏。目前,使用这些宏的任何代码都已过时,因为所有现代Windows版本都是基于Unicode的。

#1


26  

_T stands for “text”. It will turn your literal into a Unicode wide character literal if and only if you are compiling your sources with Unicode support. See http://msdn.microsoft.com/en-us/library/c426s321.aspx.

_T代表“文字”。当且仅当您使用Unicode支持编译源时,它才会将您的文字转换为Unicode宽字符文字。请参阅http://msdn.microsoft.com/en-us/library/c426s321.aspx。

#2


12  

From MSDN:

来自MSDN:

Use the _T macro to code literal strings generically, so they compile as Unicode strings under Unicode or as ANSI strings (including MBCS) without Unicode

使用_T宏一般编码文字字符串,因此它们在Unicode下编译为Unicode字符串或在没有Unicode的情况下编译为ANSI字符串(包括MBCS)

#3


11  

It's actually used for projects where Unicode and ANSI support is required. It tells the compiler to compile the string literal as either Unicode or ANSI depending on the value of a precompiler define.

它实际上用于需要Unicode和ANSI支持的项目。它告诉编译器将字符串文字编译为Unicode或ANSI,具体取决于预编译器定义的值。

Why you would want to do this is another matter. If you want to support Unicode by itself then just write Unicode, in this case L"Hello". The _T() macro was added when you needed to support Windows NT and later (which support Unicode) and Windows 9x/ME (which do not). These days any code using these macros is obsolete, since all modern Windows versions are Unicode-based.

为什么你想要这样做是另一回事。如果您想单独支持Unicode,那么只需编写Unicode,在本例中为L“Hello”。当您需要支持Windows NT及更高版本(支持Unicode)和Windows 9x / ME(不支持Unicode)时,会添加_T()宏。目前,使用这些宏的任何代码都已过时,因为所有现代Windows版本都是基于Unicode的。