The role of string-related macro _t, Text,_text, and L in VC (simple and straightforward)

Source: Internet
Author: User

One, in front of the string with an L function: such as L "my string" means the ANSI string is converted to Unicode string, that is, each character occupies two bytes.     Strlen ("ASD") = 3; Strlen (L "ASD") = 6;

The _t macro can enclose a quoted string, depending on your environment settings, so that the compiler chooses the appropriate (Unicode or ANSI) character processing based on the compiled target environment if you have defined Unicode, then the _t macro will precede the string with an L.    At this point _t ("ABCD") is equivalent to L "ABCD", which is a wide string. If there is no definition, then the _t macro does not precede the string with that l,_t ("ABCD") equivalent to "ABCD"

Third, Text,_text and _t the same

such as the following three statements: TCHAR szstr1[] = TEXT ("str1");     Char szstr2[] = "STR2";     WCHAR szstr3[] = L ("Str3");    The first sentence, when defined as Unicode, is interpreted as a third sentence, which is equal to the second sentence when it is not defined.     But two words whether or not Unicode is defined produces an ANSI string, and the third sentence always generates a Unicode string.     For the portability of the program, it is recommended to use the first presentation method. However, in some cases, a character must be ANSI or Unicode, then use the latter two

http://blog.csdn.net/adcxf/article/details/2540992

The role of string-related macro _t, Text,_text, and L in VC (simple and straightforward)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.