Documentation

UnicodeFormat.UTF16

UTF-16 #

A code point below U+10000 is a single code unit. A code point from U+10000 to U+10FFFF is a surrogate pair: a high surrogate in D800–DBFF carrying the top ten bits of c - 0x10000, then a low surrogate in DC00–DFFF carrying the bottom ten bits. A surrogate that is not part of such a pair is ill-formed.

Decoding uses the decoder of UTF16.decodeIter. decode reports the position of the first unpaired surrogate, as an index in the slice.

The UTF-16 code units of c: one for a character of the BMP, two for a surrogate pair.

Instances For

    The UTF-16 encoding of s.

    Instances For

      Decodes the UTF-16 code units of s, or returns an error with the index in s of the first unpaired surrogate.

      Instances For

        Decodes the UTF-16 code units of s, or returns none if s has an unpaired surrogate.

        Instances For

          Decodes the UTF-16 code units of s, panicking if s has an unpaired surrogate.

          Instances For

            Decodes the UTF-16 code units of s, replacing each unpaired surrogate with U+FFFD.

            Instances For

              Whether s is well-formed UTF-16, that is, has no unpaired surrogate.

              Instances For