Skip to content

utils/utf8

Documentation

Overview

Classes

UTF8

encode()

Encodes the input (either a standard JavaScript string or a raw byte array) into a UTF-8 encoded string representation.

ts
static encode(input: any): string;
ParameterTypeDescription
inputanyThe text string to be encoded, or a byte array to convert to its string representation.

Returns

  • Type: string
  • Description: The resulting UTF-8 encoded string.

decode()

Decodes the input (either a UTF-8 encoded string or a raw byte array) back into a standard JavaScript string.

ts
static decode(input: any): string;
ParameterTypeDescription
inputanyThe UTF-8 encoded string or byte array to be decoded.

Returns

  • Type: string
  • Description: The resulting standard decoded string.

bytesToString()

Decodes a specific segment of a raw byte array into a standard string using UTF-8 encoding.

ts
static bytesToString(bytes: any, offset: number, length: number): string;
ParameterTypeDescription
bytesanyThe raw byte array containing the UTF-8 data.
offsetnumberThe starting index (inclusive) from which to begin decoding.
lengthnumberThe number of bytes to decode starting from the offset.

Returns

  • Type: string
  • Description: The decoded string segment.