isContinuation(_:)
Returns a Boolean value indicating whether the specified code unit is a UTF-8 continuation byte.
Declaration
static func isContinuation(_ byte: Unicode.UTF8.CodeUnit) -> BoolParameters
- byte:
A UTF-8 code unit.
Return Value
true if byte is a continuation byte; otherwise, false.
Discussion
Continuation bytes take the form 0b10xxxxxx. For example, a lowercase “e” with an acute accent above it ("é") uses 2 bytes for its UTF-8 representation: 0b11000011 (195) and 0b10101001 (169). The second byte is a continuation byte.
let eAcute = "é"
for codeUnit in eAcute.utf8 {
print(codeUnit, UTF8.isContinuation(codeUnit))
}
// Prints "195 false"
// Prints "169 true"