1

是否有与 LPTSTR 等效的字符串?我知道字符串和 wstring。有tstring吗?

4

2 回答 2

9

你可以定义一个:

typedef std::basic_string<TCHAR> mystring;
...
mystring test = _T("Hello World!");
于 2009-12-01T06:53:28.517 回答
4

另一种选择(不需要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

用法:

ustring_t mystr = TEXT("hello world");
于 2009-12-01T07:14:00.973 回答