Encoding functions
These functions can be used to encode and decode data into other formats, such as base64 and CBOR (Concise Binary Object Representation). It is particularly used when that data needs to be stored and transferred over media that are designed to deal with text. This encoding and decoding helps to ensure that the data remains intact without modification during transport.
| Function | Description |
|---|---|
encoding::base64::decode() | This function is used to decode data. |
encoding::base64::encode() | This function is used to encode data with optionally padded output. |
encoding::cbor::decode() | This function is used to decode data. |
encoding::cbor::encode() | This function is used to encode data. |
encoding::base64::encode()
The encoding::base64::encode() function encodes a bytes to base64 with optionally padded output.
The following example shows this function, and its output, when used in a RETURN statement:
As of version 2.3.0, you can pass true as the second argument to enable padded base64 outputs:
encoding::base64::decode()
The encoding::base64::decode() function decodes a string into bytes.
The following example shows this function, and its output, when used in a RETURN statement:
You can also verify that the output of the encoded value matches the original value.
encoding::cbor::decode()
The encoding::cbor::decode() function decodes bytes in valid CBOR format into a SurrealQL value.
encoding::cbor::encode()
The encoding::cbor::encode() function encodes any SurrealQL value into bytes in CBOR format.