Are UTF16 (as used by for example wide-winapi functions) characters always 2 byte long?

前端 未结 8 1193
半阙折子戏
半阙折子戏 2021-02-09 06:23

Please clarify for me, how does UTF16 work? I am a little confused, considering these points:

  • There is a static type in C++, WCHAR, which is 2 bytes long. (alway
8条回答
  •  滥情空心
    2021-02-09 06:54

    Windows' WCHAR is 16 bits (2 bytes) long.

    A Unicode codepoint may be represented by one or two of these WCHAR – 16 or 32 bits (2 or 4 bytes).

    wcslen returns number of WCHAR units in a wide string, while wcslen_l returns the number of (locale-dependent) codepoints. Obviously, wcslen <= wcslen_l.

    A Unicode character may consist of multiple combining codepoints.

提交回复
热议问题