assertIsWellFormedUtf8String
Asserts that a given string can be encoded as UTF-8 without loss.
JavaScript strings are sequences of UTF-16 code units and may contain
lone surrogates, which have no UTF-8 representation. TextEncoder
silently replaces them with the replacement character (U+FFFD);
this function throws instead.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | string | The string to validate. |
Returns
void
Throws
If value contains a lone surrogate.