MBCS , 多位元組字元集 (Multibyte Character Set,MBCS)
-----------------------------------------------------
LP = long point
一般LP代表指針,C代表const,T代表寬字符,STR代表字符串
CString 是封裝好的字符串處理類。包括一個LPCTSTR對象以及若幹字符串操作。
LPSTR 就是一個字符串指針類型
LPBYTE 是BYTE的指針類型
WORD 是兩個字節的無符號整數
BYTE 是一個字節的無符號整數
CString 是一個MFC字符串類,可以當LPCSTR使用或者LPCWSTR使用
LPSTR = char* ,4 byte
LPBYTE = BYTE* ,4 byte
WORD = short ,2 byte
BYTE = unsigned char
LPCTSTR = const unsigned short* (IN UNICODE)
LPCTSTR = CONST TCHAR* [為32bit的常數字串,它可移植到Unicode和DBCS(變位元組字集)中]
LPCTSTR = const TCHAR*
--------------------
_T -> ANSI、UNICODE的轉換
--------------------
UNICODE中
LPCTSTR、LPTSTR、_T、CString有不同的看法
----------------------------------------
char 資料的儲存值是該字元的ASCII值(整數)
----------------------------------------
wchar_t
是Unicode字符的數據類型,它實際定義在裡:
不能使用似strcpy的ANSI C字符串函理wchar_t字符串
必使用wcs前的函,例如wcscpy。了器Unicode字符串
必以在前面加一“L”,例如:
wchar_t *szTest=L"This is a Unicode string.";
----------------------------
TChar = char + wchar_t (MBCS or Unicode)
------------------------
以strcpy函數為例子,總結一下:
.如果你想使用ANSI字符串,那麼請使用這一套寫法:
char szString[100];
strcpy(szString,"test");
.如果你想使用Unicode字符串,那麼請使用這一套:
wchar_t szString[100];
wcscpyszString,L"test");
.如果你想通過定義_UNICODE,而編譯ANSI或者Unicode字符串代碼:
TCHAR szString[100];
_tcscpy(szString,_TEXT("test"));
==========================================
Strings
•Series of characters treated as a single unit
•Can include letters, digits and special characters (*, /, $)
•"Hello" 系統處理時最後面會自動加一個‘\0’
•String = a pointer to the first character
•Value of string is the address of first character
•Remember that strings represented as character arrays end with '\0'
•Define
char color[] = "blue";
char *colorPtr = "blue";
--------------------
MSDN
WORD A 16-bit unsigned integer.
DWORD A 32-bit unsigned integer or the address of a segment an its associated offset.
BYTE An 8-bit integer that is not signed.
LONG A 32-bit signed integer.
UINT A 16-bit unsigned integer on Windows versions 3.0、3.1; a 32-bit unsigned integer on Win32.
TCHAR A Win32 character string that can be used to describe ANSI, DBCS, or Unicode strings
LPCSTR A 32-bit pointer to a constant character string.
LPSTR A 32-bit pointer to a character string.
LPCTSTR A 32-bit pointer to a constant character string that is portable for Unicode and DBCS.
LPTSTR A 32-bit pointer to a character string that is portable for Unicode and DBCS.
LPVOID A 32-bit pointer to an unspecified type.
WNDPROC A 32-bit pointer to a window procedure.
- Nov 11 Fri 2011 18:08
[C++] 型別
全站熱搜
留言列表