Function Updated 17 Oct 2026
textDecode(bytes, [encoding])
Converts a byte array to a string using the specified encoding.
Parameters
bytesbyte[]requiredThe byte array to decode, for example from textEncode() or getEmbeddedFile(). Any other value returns null.
encodingstringoptionalutf8 (default, also utf-8), utf32, unicode (UTF-16 little-endian, also utf), bigendianunicode, ascii, utf7 or default (UTF-8). Case-insensitive. An unknown name returns null.
Returns
A string. null if the value is not a byte array or the encoding is unknown.
Example
Normal JavaScript, running in the browser or on the Docly™ server.
// Encoding a string into bytes
let bytes = docly.textEncode("Hello, world!", "utf8");
// Decoding bytes back into a string
let str = docly.textDecode(bytes, "utf8");
write(str); // Outputs: Hello, world!The JavaScript above produces this output:
Hello, world!