mirror of
https://github.com/apple/swift-nio
synced 2026-11-27 05:04:22 +00:00
Add methods to ByteBuffer to read validated UTF8 strings ### Motivation: The current `readString` and `getString` methods of `ByteBuffer` do not verify that the string being read is valid UTF8. The Swift 6 standard library comes with a new initialiser `String(validating:as:)`. This PR adds alternative methods to ByteBuffer which uses this instead of `String(decoding:as:)`. ### Modifications: Added `ByteBuffer.getUTF8ValidatedString(at:length:)` Added `ByteBuffer.readUTF8ValidatedString(length:)` ### Result: You can read strings from a ByteBuffer and be certain they are valid UTF8 --------- Co-authored-by: Cory Benfield <lukasa@apple.com>