본문 바로가기

프로그래밍 활용(TIP)

LPSTR -> std::string 변환

참고 : http://msdivy.blogspot.kr/2013/03/convert-lptstr-to-stdstring.html


Convert LPTSTR  to std::string

Non-unicode:
LPTSTR l = "Test";
string s = l;

Unicode:
LPTSTR l = L("Test");
wstring w = l;
string s (w .begin(), w .end() );


위 내용에서 'Non-unicode' 와  'Unicode'의 확인은 아래 참고


*Visual Studio 2005 기준(타 버전은 다를 수 있음)

-VS의 상단 메뉴에서 [프로젝트] - [속성] - [일반] -[프로젝트 기본값] 항목에서 문자 집합 항목 확인.

-'멀티바이트 문자 집합 사용' 은 Non-unicode , '유니코드 문자 집합 사용'은 Unicode.