Is there an string equivalent to LPTSTR?

强颜欢笑 提交于 2019-12-11 11:28:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!