Starting a new Windows app: Should I use _TCHAR or wchar_t for text?

前端 未结 5 2038
梦谈多话
梦谈多话 2021-01-06 04:01

I\'m coding up a new (personal hobby) app for Windows in c++.

In previous low-level Windows stuff I\'ve used _TCHAR (or just TCHAR) arrays/basic_strings

5条回答
  •  孤城傲影
    2021-01-06 04:36

    If you always compile your app for Unicode while you are developing it, IT WILL NOT WORK when compiled for ANSI strings, even if it is crammed full of TCHARs. (Toy apps excepted.)

    That's what JaredPar was getting at when he said ANSI is not a valid target. If you want to maintain Unicode and ANSI versions, you can use TCHAR to do that, but just using TCHAR and other T's won't get you there - you have to actively build and maintain both versions. Definitely not worth it anymore for most apps.

提交回复
热议问题