Difference between char* and wchar_t*

前端 未结 4 1804
青春惊慌失措
青春惊慌失措 2020-12-30 09:59

I am new to MFC. I am trying to do simple mfc application and I\'m getting confuse in some places. For example, SetWindowText have two api, SetWindowTextA

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-30 10:25

    char is used for so called ANSI family of functions (typically function name ends with A), or more commonly known as using ASCII character set.

    wchar_t is used for new so called Unicode (or Wide) family of functions (typically function name ends with W), which use UTF-16 character set. It is very similar to UCS-2, but not quite it. If character requires more than 2 bytes, it will be converted into 2 composite codepoints, and this can be very confusing.

    If you want to convert one to another, it is not really simple task. You will need to use something like MultiByteToWideChar, which requires knowing and providing code page for input ANSI string.

提交回复
热议问题