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

后端 未结 8 1604
广开言路
广开言路 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.

提交回复
热议问题