-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ByteBuffer methods getUTF8ValidatedString and readUTF8ValidatedSt…
…ring (#2973) 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 <[email protected]>
- Loading branch information
1 parent
035d3a5
commit 74cf44e
Showing
2 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters