In C++ when to use WCHAR and when to use CHAR

前端 未结 5 1670
春和景丽
春和景丽 2020-12-14 03:56

I have a question:

Some libraries use WCHAR as the text parameter and others use CHAR (as UTF-8): I need to know when to use WCHAR or CHAR when I write my own librar

5条回答
  •  伪装坚强ぢ
    2020-12-14 04:02

    It is best recommended that, when developing a Windows application, resort to TCHARs. The good thing about TCHARs is that they can be either regular chars or wchars, depending whether the unicode setting is set or not. Once you resort to TCHARs, you make sure that all string manipulations that you use also start with the _t prefix (e.g. _tcslen for length of string). That way you will know that your code will work both in Unicode and ASCII environments.

提交回复
热议问题