1. Docs

Codec

The IronWeb codec namespace provides utility methods to convert data between different formats. Because the input and output of the IronWeb SDK is either in bytes or Base64 encoded strings, these methods provide a way to convert content between bytes and strings.

utf8.toBytes()

IronWeb.codec.utf8.toBytes(content)

Converts a valid UTF-8 string into bytes.

Parameters

Parameter Name Value Description
content string UTF-8 encoded string to convert into bytes.

Response

Returns bytes if successful (i.e. the string passed in is a valid UTF-8 string).

utf8.fromBytes()

IronWeb.codec.utf8.fromBytes(utf8Bytes)

Converts a sequence of valid UTF-8 bytes into a string.

Parameters

Parameter Name Value Description
utf8Bytes Uint8Array Byte array of valid UTF-8 bytes

Response

Returns a UTF-8 string if successful (i.e. the bytes passed in are valid UTF-8 bytes).

base64.toBytes()

IronWeb.codec.base64.toBytes(base64String)

Converts a string of Base64 encoded content into bytes.

Parameters

Parameter Name Value Description
base64String string Base 64 string to be encoded.

Response

Byte array of content passed in.

base64.fromBytes()

IronWeb.codec.base64.fromBytes(byteArray)

Converts an array of bytes into a Base64 encoded string.

Parameters

Parameter Name Value Description
byteArray Uint8Array An array containing bytes to convert into a string.

Response

If successful, this method returns a base 64 encoded string of the original Uint8Array that was passed in.

Was this page helpful?