问题
Is there an string equivalent to LPTSTR? I know of string and wstring. Is there a tstring?
回答1:
You could define one:
typedef std::basic_string<TCHAR> mystring;
...
mystring test = _T("Hello World!");
回答2:
Another option (doesn't require windows.h
):
#if defined(_UNICODE) || defined(UNICODE)
typedef std::wstring ustring_t;
typedef wchar_t uchar_t;
#define TEXT(x) (L##x)
#else
typedef std::string ustring_t;
typedef char uchar_t;
#define TEXT(x) (x)
#endif
Usage:
ustring_t mystr = TEXT("hello world");
来源:https://stackoverflow.com/questions/1824420/is-there-an-string-equivalent-to-lptstr