Confused about C++'s std::wstring, UTF-16, UTF-8 and displaying strings in a windows GUI

后端 未结 5 1687
长发绾君心
长发绾君心 2020-12-28 17:21

I\'m working on a english only C++ program for Windows where we were told \"always use std::wstring\", but it seems like nobody on the team really has much of an understandi

5条回答
  •  春和景丽
    2020-12-28 17:33

    Windows from NT4 onwards is based on Unicode encoded strings, yes. Early versions were based on UCS-2, which is the predecessor of UTF-16, and thus does not support all of the characters that UTF-16 does. Later versions are based on UTF-16. Not all OSes are based on UTF-16/UCS-2, though. *nix systems, for instance, are based on UTF-8 instead.

    UTF-8 is a very good choice for storing data persistently. It is a universally supported encoding in all Unicode environments, and it is a good balance between data size and loss-less data compatibility.

    Yes, you would have to parse the XML, extract the necessary information from it, and decode and transform it into something the UI can use.

提交回复
热议问题