hammerspoon2-docs
    Preparing search index...

    Function decodeText

    • Decodes bytes as UTF-8 text. Data from readBytes() or readAvailable() can end part-way through a multi-byte character, whose remaining bytes arrive in the next read. Such bytes aren't valid UTF-8 on their own, so join the reads' bytes before decoding them, or use readUntil() with a delimiter, whose data always ends with a complete character.

      Parameters

      • bytes: ArrayBuffer | Uint8Array<ArrayBufferLike>

        The bytes to decode, e.g. the data from a "data" event.

      • Optionallossy: boolean

        true to replace invalid or incomplete UTF-8 with the replacement character (U+FFFD) instead of returning null. Defaults to false.

      Returns string | null

      The text, or null if the bytes aren't valid UTF-8 (including when they end part-way through a character) and lossy isn't true.