findMalformedUtf8SequenceOffset
Finds the first malformed UTF-8 sequence in the given bytes, from the given offset.
This rejects everything the Unicode standard rejects: unexpected continuation
bytes, overlong encodings, encoded surrogates, code points above U+10FFFF
and truncated sequences.
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
number
The offset at which the first malformed sequence starts, or -1 if the bytes are well-formed.