Skip to content

happypdf / utf16Decode

Function: utf16Decode()

ts
function utf16Decode(input, byteOrderMark?): string;

Defined in: src/utils/unicode.ts:283

Decodes a Uint8Array of data to a string using UTF-16.

Note that this function attempts to recover from erronous input by inserting the replacement character (�) to mark invalid code points and surrogate pairs.

Parameters

ParameterTypeDefault valueDescription
inputUint8ArrayundefinedA Uint8Array containing UTF-16 encoded data
byteOrderMarkbooleantrueWhether or not a byte order marker (BOM) should be read at the start of the encoding. (default true)

Returns

string

The decoded string.

MIT Licensed. A fork of pdf-lib.