struct UTF8

A codec for UTF-8.

Inheritance UnicodeCodecType View Protocol Hierarchy →
Associated Types
CodeUnit = UInt8

A type that can hold code unit values for this encoding.

Import import Swift





Static Methods

static func encode(_:output:)

Encode a UnicodeScalar as a series of CodeUnits by calling output on each CodeUnit.


static func encode(input: UnicodeScalar, output put: (CodeUnit) -> Void)
static func isContinuation(_:)

Returns true if byte is a continuation byte of the form 0b10xxxxxx.


static func isContinuation(byte: CodeUnit) -> Bool

Instance Methods

mutating func decode(inout:)

Start or continue decoding a UTF sequence.

In order to decode a code unit sequence completely, this function should be called repeatedly until it returns UnicodeDecodingResult.EmptyInput. Checking that the generator was exhausted is not sufficient. The decoder can have an internal buffer that is pre-filled with data from the input generator.

Because of buffering, it is impossible to find the corresponding position in the generator for a given returned UnicodeScalar or an error.

next: A generator of code units to be decoded.


mutating func decode<G : GeneratorType where G.Element == CodeUnit>(inout next: G) -> UnicodeDecodingResult