utf8.decode

Decodes UTF-8 bytes into a string.

Syntax

decode(bytes)

Parameters

Return value

A decoded string.

Invalid characters are replaced with the Unicode replacement character "\uFFFD".

Example

utf8.decode(new Uint8Array([104, 101, 108, 108, 111, 32, 240, 159, 144, 165]))
"hello 🐥"
// same as
new TextDecoder().decode(new Uint8Array([104, 101, 108, 108, 111, 32, 240, 159, 144, 165]))
"hello 🐥"