How does Microsoft handle the fact that UTF-16 is a variable length encoding in their C++ standard library implementation

前端 未结 5 2427
小蘑菇
小蘑菇 2021-02-20 08:48

Having a variable length encoding is indirectly forbidden in the standard.

So I have several questions:

How is the following part of the standard handled?

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-20 09:45

    Two things:

    1. There is no "Microsoft STL implementation". The C++ Standard Library shipped with Visual C++ is licensed from Dinkumware.
    2. The current C++ Standard knows nothing about Unicode and its encoding forms. std::wstring is merely a container for wchar_t units which happen to be 16-bit on Windows. In practice, if you want to store a UTF-16 encoded string into a wstring, just take into account that you are really storing code units and not code points.

提交回复
热议问题