Starts or continues decoding a UTF-16 sequence.
- Xcode 9.0+
- Swift Standard Library
An iterator of code units to be decoded.
inputmust be the same iterator instance in repeated calls to this method. Do not advance the iterator or any copies of the iterator outside this method.
Unicode instance, representing the next Unicode scalar, an indication of an error, or an indication that the UTF sequence has been fully decoded.
To decode a code unit sequence completely, call this method repeatedly until it returns
Unicode. Checking that the iterator was exhausted is not sufficient, because the decoder can store buffered data from the input iterator.
Because of buffering, it is impossible to find the corresponding position in the iterator for a given returned
Unicode or an error.
The following example decodes the UTF-16 encoded bytes of a string into an array of
Unicode instances. This is a demonstration only—if you need the Unicode scalar representation of a string, use its