_ T will automatically convert Unicode and non-Unicode according to your project settings.
Add L to convert to Unicode top
2nd floor Dumack ( Tian LAN ) Reply 2001-12-18 11:25:07 Score 0 _ T is to convert the string to tchar, and tchar is a macro definition. When Unicode is defined, tchar is equivalent to wchar, otherwise it is equivalent to Char. To be compatible with the platform in the future, we recommend that you use tchar instead of a common char. Example: tchar * s = _ T ("fsdf ")
L converts a string to wchar, which is used in the Unicode environment. Example: wchar * s = l "fsdf" Top
Third floor Chenxiaocang ( King of the Town Prison ) Reply 2001-12-18 11:51:00 Score 0 So I use it like this:
Setwindowtext (_ T ("I'm fine "));
It works normally on the Chinese Win2000, but is garbled in the English Win2000? Top
4th floor Hxd1114 ( Furious ) Reply 2001-12-18 11:52:44 Score 0 English Win2k ?? It seems like it should be garbled, right? @@~~ :( (Top
5th floor Chenxiaocang ( King of the Town Prison ) Reply 2001-12-18 13:38:07 Score 0 Help top
6th Floor Supperapplication ( Planet ) Reply 2001-12-18 13:47:39 Score 0 Haha ~~ Of course it is garbled. Top
7 th floor CMPP ( ) Reply 2001-12-21 14:20:54 Score 0 Let me learn! Top
8 th floor Xiaoxiaohan ( Xiao Xiaohan ) Reply 2001-12-27 13:00:01 Score 0 UNICODE: Wide-Byte Character Set
1. How to obtain the number of characters in a string that contains both single-byte and double-byte characters?
You can call the Runtime Library of Microsoft Visual C ++ to contain the function _ mbslen to operate multi-byte strings (including single-byte and dual-byte strings.
Calling the strlen function does not really know how many characters are in the string. It only tells you how many bytes are before the end of 0.
2. How to operate on DBCS strings?
Function Description
Ptstr charnext (lpctstr); returns the address of the next character in the string
Ptstr charprev (lpctstr, lpctstr); returns the address of the previous character in the string.
Bool isdbcsleadbyte (byte); if this byte is the first byte of the DBCS character, a non-zero value is returned.
3. Why Unicode?
(1) It is easy to exchange data between different languages.
(2) enable you to allocate a single. EXE file or DLL file that supports all languages.
(3) Improve applications Program .
Windows 2000 is developed from scratch using Unicode. If you call any windows function and pass it an ANSI string, the system must first convert the string to Unicode, then, the Unicode string is passed to the operating system. If you want the function to return an ANSI string, the system first converts the Unicode string to an ANSI string and then returns the result to your application. To convert these strings, the system time and memory are required. By developing applications with Unicode from the beginning, you can make your applications run more effectively.
Windows CE itself is an operating system that uses Unicode and does not support ANSI Windows functions.
Windows 98 only supports ANSI and can only develop applications for ANSI.
When Microsoft converts com from a 16-bit windows to Win32, the company determines that all the COM interface methods that require strings can only accept Unicode strings.
4. How to Write Unicode Source code ?
Microsoft has designed windowsapi for Unicode, which can be minimized. Code . In fact, you can write a single source code file to compile it with or without Unicode. You only need to define two macros (Unicode and _ Unicode) to modify and re-compile the source file.
_ Unicode macro is used for the C Runtime header file, while Unicode macro is used for the Windows header file. When compiling the source code module, these two macros must be defined at the same time.
5. What Unicode data types are defined in windows?
Data Type description
Wchar Unicode Character
Pwstr pointer to Unicode string
Pcwstr pointer to a constant Unicode string
The corresponding ANSI data types are char, lpstr, and lpcstr.
The Common Data Types of ANSI/Unicode are tchar, ptstr, and lpctstr.
6. How to operate Unicode?
Character Set feature instance
ANSI operation functions start with str strcpy
Unicode operation functions start with the WCS wcscpy
The MBCS operation function starts with _ MBS _ mbscpy
ANSI/Unicode operation functions start with _ TCS _ tcscpy (C Runtime Library)
ANSI/Unicode operation functions start with lstr lstrcpy (Windows function)
All new and outdated functions have both ANSI and Unicode versions in Windows2000. Functions of the ANSI version end with a, and functions of the Unicode version end with W. Windows will be defined as follows:
# Ifdef Unicode
# Define createmediawex createmediawexw
# Else
# Define createmediawex createmediawexa
# Endif //! Unicode
7. How do I represent Unicode string constants?
Character Set instance
ANSI "string"
Unicode L "string"
ANSI/Unicode T ("string") or _ text ("string") if (szerror [0] ==_ text ('J ')){}
8. Why should I try to use operating system functions?
Secret. Because these functions are used a lot, they may have been loaded into RAM when the application is running.
Such as strcat, strchr, strcmp, and strcpy.
9. How do I write ANSI and Unicode-compliant applications?
(1) treat a text string as a character array instead of a chars array or byte array.
(2) Use common data types (such as tchar and ptstr) for text characters and strings.
(3) Use explicit data types (such as byte and pbyte) for byte, byte pointer, and data cache.
(4) use the text macro for the original characters and strings.
(5) perform global replacement (for example, replace pstr with ptstr ).
(6) Modifying string operations. For example, a function usually needs to pass a cached size in characters, rather than bytes. This means that sizeof (szbuffer) should not be passed, but sizeof (szbuffer)/sizeof (tchar) should be passed ). In addition, if you need to allocate a memory block to the string and have the number of characters in the string, remember to allocate memory by byte. This means that you should call malloc (ncharacters * sizeof (tchar) instead of malloc (ncharacters ).
10. How to compare the selected strings?
It is implemented by calling comparestring.
Logo meaning
Norm_ignorecase ignores uppercase and lowercase letters
Norm_ignorekanatype does not distinguish hirakana from katakana
Norm_ignorenonspace ignore no delimiter
Norm_ignoresymbols ignore symbols
Norm_ignorewidth does not distinguish between single-byte characters and double-byte characters.
Sort_stringsort uses punctuation marks as common symbols.
11. How can I determine whether a text file is ANSI or Unicode?
It is determined that if the first two bytes of the text file are 0xff and 0xfe, It is Unicode, otherwise it is ANSI.
12. How can I determine whether a string is ANSI or Unicode?
Use istextunicode for determination. Istextunicode uses a series of statistical and qualitative methods to guess the cached content. Because this is not an exact scientific method, istextunicode may return incorrect results.
13. How to convert a string between Unicode and ANSI?
The Windows function multibytetowidechar is used to convert a multi-byte string to a wide string. The function widechartomultibyte converts a wide string to an equivalent multi-byte string.