윈도우 프로그래밍

string, wstring and tstring

xaida 2020. 6. 16. 10:44

전형적인 윈도우 스타일.

string과 wstring 사이에서 혼란을 겪지 않아도 되므로 편리함

 

사용법 - 아래 선언을 stdafx.h에 포함해서 사용

1)

#ifdef _UNICODE
typedef std::wstring tstring;
#else
typedef std::string tstring;
#endif

2)

typedef std::basic_string<TCHAR> tstring;

std::string은 std::basic_string<char>의 인스턴스,

std::wstring은 std::basic_string<wchar>의 인스턴스이다.

따라서 std::basic_string<TCHAR>로 가능함.

 

 

 

출처 : https://m.blog.naver.com/PostView.nhn?blogId=nine01223&logNo=220443106588&proxyReferer=https:%2F%2Fwww.google.com%2F