Why was wchar_t invented?

前端 未结 10 1702
说谎
说谎 2021-01-03 20:15

Why is wchar_t needed? How is it superior to short (or __int16 or whatever)?

(If it matters: I live in Windows world. I don\'t

10条回答
  •  萌比男神i
    2021-01-03 21:11

    wchar_t is a bit of a hangover from before unicode standardisation. Unfortunately it's not very helpful because the encoding is platform specific (and on Solaris, locale-specific!), and the width is not specified. In addition there are no guarantees that utf-8/16/32 codecvt facets will be available, or indeed how you would access them. In general it's a bit of a nightmare for portable usage.

    Apparently c++0x will have support for unicode, but at the current rate of progress that may never happen...

提交回复
热议问题