Skip to main content

Encoding APIs

These functions are related to encoding data

encode(data) -> string​

Base64 encode raw bytes. The encoding is not URL safe

ParamTypeDescription
dataUint8ArrayThe raw bytes to encode

decode(b64) -> Uint8Array | EncodingError​

Decode a valid RFC4648 Base64 encoded string

ParamTypeDescription
b64stringA base64 encoded string

encodeBytes(data) -> Uint8Array​

Convert provided string to raw bytes

ParamTypeDescription
datastringString to convert to bytes

extractUtf8String(data) -> string​

Extract a UTF8 string from provided bytes

ParamTypeDescription
dataUint8ArrayRaw bytes to extract UTF8 string from

extractUtf16String(data) -> string​

Extract a UTF16 string from provided bytes

ParamTypeDescription
dataUint8ArrayRaw bytes to extract UTF16 string from

bytesToHexString(data) -> string​

Convert bytes to Hex string

ParamTypeDescription
dataUint8ArrayRaw bytes to convert to hex

readXml(path) -> Record<string, unknown> | EncodingError​

Read a XML file into a JSON object. Supports either UTF8 or UTF16 encoded XML files

ParamTypeDescription
pathstringPath to XML file to read

generateUuid() -> string​

Generates a UUID v4 hyphenated string

formatGuid(format, data) -> string​

Format provided bytes into a GUID hyphenated string based on provided Endianness. Must provide exactly 16 bytes. Windows is commonly Little Endian. macOS is commonly Big Endian

ParamTypeDescription
formatEndianEndianness type LE or BE
dataUint8ArrayRaw bytes to format to GUID

parseProtobufBytes(raw_bytes) -> Record<string, unknown> | EncodingError​

An experimental protobuf parser. Artemis will attempt to parse the provided protobuf bytes and return a JSON object. Binary protobuf data is a blackbox, it is typically not possible to perfectly parse protobuf data perfectly every time.

Artemis will return a JSON object if it can parse the entire data

See:

ParamTypeDescription
raw_bytesUint8ArrayRaw protobuf bytes

readCsv(path) -> Record<string, string>[] | EncodingError​

Read a CSV file into a JSON object. The CSV file must have a header row.

ParamTypeDescription
pathstringPath to CSV file to read
offsetnumberRow to start reading at. Default is first non-header row
limitnumberHow many rows to read. Default is 100