assertIsWellFormedUtf8Bytes
Asserts that the given bytes, from the given offset, form well-formed UTF-8.
TextDecoder silently replaces malformed sequences with the replacement
character (U+FFFD); this function throws instead.
See findMalformedUtf8SequenceOffset for what counts as malformed.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | | ReadonlyUint8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | The byte array to validate. |
offset? | number | The offset from which to start validating (defaults to 0). |
Returns
void
Throws
If a malformed sequence is found, reporting its offset.