TextDecode(bytes, [encoding]) Last updated: 13. Nov 2023

Converts a byte array to a string using the specified encoding.

Parameters

Name Type Description
bytes byte[]
encoding (optional) string Default is UTF8

Returns

A string.

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
// Encoding a string into bytes
let bytes = docly.TextEncode('Hello, world!', 'utf8');
console.log(bytes); // Outputs: <Buffer 48 65 6c 6c 6f 2c 20 77 6f 72 6c 64 21>

// Decoding bytes back into a string
let str = docly.TextDecode(bytes, 'utf8');
console.log(str); // Outputs: Hello, world!