Please Enable JavaScript!
Gon[ Enable JavaScript ]

CString 의 데이타 타입에 관한 정리표

기타 언어/C# & MFC
반응형

프로그램시 제일 많이 쓰이는 문자열 타입에 대한 정리의 필요성을 느꼈다.
아래표를 보고 문자열사용시 타입들을 적절하게 활용할수 있게 되었다.

기본 language type

char

8-bit signed value, 범위 -128..127. 

unsigned char

8-bit unsigned character value, 범위 0..255. 

char *

8-bit signed character values point.  마지막이 NULL 로 끝난다

const char *

A pointer to a sequence of 8-bit signed character values

wchar_t

A 16-bit signed character value (wide character type), 범위 -32768..32767. 

컴파일러가 유니코드 character 로 인식한다.

unsigned wchar_t

A 16-bit unsigned character value (wide character type), range 0..65536. 

wchar_t *

A pointer to a sequence of 16-bit signed character values. 

마지막이 NULL 로 끝난다

const wchar_t *

A pointer to a sequence of 16-bit signed character values. 

'c'

An 8-bit signed character constant.  엄격히 말하면 글자의 int 값을 나타낸다.

"xxx"

A string of 8-bit characters.  4 byte 의 크기를 나타내며 마지막 한 byte NULL

을 표현한다.

L'c'

A 16-bit signed character constant.유니코드 타입이며 한글자에 2바이트를 부여한다

L"xxx"

A string of 16-bit characters.  8 byte 의 크기를 나타내며 마지막 한 byte NULL


윈도우 프로그램에서 쓰이는 Windows Types

CHAR

8-bit signed character type. 

LPSTR, PSTR

Pointer to 8-bit signed character sequence.  char * 같은 표현이다.

LPCSTR, PCSTR

Pointer to constant 8-bit signed character equence.  const char *  같은표현이다

WCHAR

16-bit signed character type. 유니코드 타입이며 wchar_t. 같은 표현이다.

LPWSTR,PWSTR

Pointer to sequence of 16-bit characters.  유니코드 타입이며 wchar_t * 같은 표현이다

LPCWSTR
PCWSTR

Pointer to a constant 16-bit signed character sequence. 

유니코드 타입이며 const wchar_t * value.

TCHAR

8-bit 혹은 16-bit character.  UNICODE 설정되어있으면 wchar_t type 이되며

아니라면 char type 이 된다.  

LPTSTR
PTSTR

A pointer to an 8-bit or 16-bit character string. 

UNICODE 설정되어있으면 wchar_t * 이되며 아니라면 char * type 된다

LPCTSTR
PCTSTR

A pointer to a constant 8-bit or 16-bit character string. 

UNICODE 설정되어있으면 const wchar_t * 이되며 아니라면 const char * type 된다

대부분의 API 들에서는 LPCTSTR a사용하고 있으며 CString 표현할때 항상 쓰인다.

_T('x')

A character literal.  UNICODE 정의하되어있으면 컴파일러는 L'x', 16bit 인식한다

그렇지않으면 'x', an 8-bit character value 인식한다.

_T("abc")

A string literal.  UNICODE p정의되어있으면 L"abc", 인식하며 그렇지 않을경우는

"abc", an 8-bit string literal NULL 로 끝나는 문자열이 된다.


여러 형태의 CString types

CString

A string data type. 

UNICODE : 16-bit wide characters  NUL 끝나며 CStringW 클래스와 같다.

NOT UNICODE : 8-bit characters, NUL 끝나며 CStringA 클래스와 같다

CStringA

A string data type. 

NOT UNICODE 의존적인 클래스 이며  8-bit characters  NUL.로 끝난다.

CStringW

A string data type. 

UNICODE 의존적인 클래스 이며 16-bit characters  NUL. 로 끝난다

CStringT

 


특수한 Other types

BSTR

Unicode string.  이것은 Visual Basic, COM, ActiveX

프로그램시 사용하는 특별한 interface type 이다.

std::string

A C++ Standard Library string

UNICODE_STRING

A kernel data type

PUNICODE_STRING

A pointer to a UNICODE_STRING structure.

PCUNICODE_STRING

A pointer to a const UNICODE_STRING structure.

 


반응형
Posted by 녹두장군1
,