readUTF8ValidatedString(length:)

Read length bytes off this ByteBuffer, decoding it as String using the UTF-8 encoding. Move the reader index forward by length.

ByteBuffer-aux.swift:947
iOS
18+
macOS
15+
tvOS
18+
watchOS
11+
mutating func readUTF8ValidatedString(length: Int) throws -> String?

Parameters

length

The number of bytes making up the string.

Returns

A String value deserialized from this ByteBuffer or nil if there aren’t at least length bytes readable.

This is an alternative to ByteBuffer.readString(length:) which ensures the returned string is valid UTF8. If the string is not valid UTF8 then a ReadUTF8ValidationError error is thrown and the reader index is not advanced.