注意: 此页面尚未翻译成中文。以下内容为英文原版。
function toUtf8Bytes(str, form?): Uint8Array
Returns the UTF-8 byte representation of str. If form is specified, the string is normalized.

Parameters

ParameterTypeDescription
strstringThe string to convert.
form?UnicodeNormalizationFormThe normalization form to use.

Returns

Uint8Array The UTF-8 byte representation.

Throws

If the UTF-8 conversion fails.

Source

encoding/utf8.ts:285