C programming: How to program for Unicode?

前端 未结 8 1080
予麋鹿
予麋鹿 2020-11-28 18:26

What prerequisites are needed to do strict Unicode programming?

Does this imply that my code should not use char types anywhere and that functions need

8条回答
  •  鱼传尺愫
    2020-11-28 19:33

    To do strict Unicode programming:

    • Only use string APIs that are Unicode aware (NOT strlen, strcpy, ... but their widestring counterparts wstrlen, wsstrcpy, ...)
    • When dealing with a block of text, use an encoding that allows storing Unicode chars (utf-7, utf-8, utf-16, ucs-2, ...) without loss.
    • Check that your OS default character set is Unicode compatible (ex: utf-8)
    • Use fonts that are Unicode compatible (e.g. arial_unicode)

    Multi-byte character sequences is an encoding that pre-dates the UTF-16 encoding (the one used normally with wchar_t) and it seems to me it is rather Windows-only.

    I've never heard of wint_t.

提交回复
热议问题