Convert ASCII string to Unicode? Windows, pure C

后端 未结 6 874
滥情空心
滥情空心 2021-01-13 06:08

I\'ve found answers to this question for many programming languages, except for C, using the Windows API. No C++ answers please. Consider the following:

#inc         


        
6条回答
  •  爱一瞬间的悲伤
    2021-01-13 07:01

    If you are really serious about Unicode, you should refer to International Components for Unicode, which is a cross-platform solution for handling Unicode conversions and storage in either C or C++.

    Your WCHAR, for example, is not Unicode to begin with, because Microsoft somewhat prematurely defined wchar_t to be 16bit (UCS-2), and got stuck in backward compatibility hell when Unicode became 32bit: UCS-2 is almost, but not quite identical to UTF-16, the latter being in fact a multibyte encoding just like UTF-8. "Wide" format in Unicode means 32 bit (UTF-32), and even then you don't have a 1:1 relationship between code points (i.e. 32bit-values) and abstract characters (i.e. a printable glyph).

    Gratuituous, losely related list of links:

    • The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) by Joel Spolsky
    • The UTF-8 Everywhere Manifesto
    • Commonly confused characters by Greg Baker

提交回复
热议问题