C++ strings: UTF-8 or 16-bit encoding?

后端 未结 8 1599
广开言路
广开言路 2021-02-04 09:42

I\'m still trying to decide whether my (home) project should use UTF-8 strings (implemented in terms of std::string with additional UTF-8-specific functions when necessary) or s

相关标签:
8条回答
  • 2021-02-04 10:47

    I would recommend UTF-16 for any kind of data manipulation and UI. The Mac OS X and Win32 API uses UTF-16, same for wxWidgets, Qt, ICU, Xerces, and others. UTF-8 might be better for data interchange and storage. See http://unicode.org/notes/tn12/.

    But whatever you choose, I would definitely recommend against std::string with UTF-8 "only when necessary".

    Go all the way with UTF-16 or UTF-8, but do not mix and match, that is asking for trouble.

    0 讨论(0)
  • 2021-02-04 10:47

    Have you considered using wxStrings? If I remember correctly, they can do utf-8 <-> Unicode conversions and it will make it a bit easier when you have to pass strings to and from the UI.

    0 讨论(0)
提交回复
热议问题