Base64

Description Base64 is an encoding that allows a sequence of arbitrary bytes to be encoded as a sequence of printable ASCII characters. For the definition of Base64, see RFC 1421 or RFC 2045. Base64 is most commonly used as a MIME transfer encoding for email. GLib supports incremental encoding using g_base64_encode_step() and g_base64_encode_close(). Incremental decoding can be done with g_base64_decode_step(). To encode or decode data in one go, use g_base64_encode() or g_base64_decode(). To avoid memory allocation when decoding, you can use g_base64_decode_inplace(). Support for Base64 encoding has been added in GLib 2.12.

Members

Static functions

decode
char[] decode(string text)

Decode a sequence of Base-64 encoded text into binary data Since 2.12

decodeInplace
char[] decodeInplace(string text)

Decode a sequence of Base-64 encoded text into binary data by overwriting the input data. Since 2.20

decodeStep
gsize decodeStep(string inn, gsize len, char* f_out, int state, uint save)

Incrementally decode a sequence of binary data from its Base-64 stringified representation. By calling this function multiple times you can convert data in chunks to avoid having to have the full encoded data in memory. The output buffer must be large enough to fit all the data that will be written to it. Since base64 encodes 3 bytes in 4 chars you need at least: (len / 4) * 3 + 3 bytes (+ 3 may be needed in case of non-zero state). Since 2.12

encode
string encode(char* data, gsize len)

Encode a sequence of binary data into its Base-64 stringified representation. Since 2.12

encodeClose
gsize encodeClose(int breakLines, string f_out, int state, int save)

Flush the status from a sequence of calls to g_base64_encode_step(). The output buffer must be large enough to fit all the data that will be written to it. It will need up to 4 bytes, or up to 5 bytes if line-breaking is enabled. Since 2.12

encodeStep
gsize encodeStep(char* inn, gsize len, int breakLines, string f_out, int state, int save)

Incrementally encode a sequence of binary data into its Base-64 stringified representation. By calling this function multiple times you can convert data in chunks to avoid having to have the full encoded data in memory. When all of the data has been converted you must call g_base64_encode_close() to flush the saved state. The output buffer must be large enough to fit all the data that will be written to it. Due to the way base64 encodes you will need at least: (len / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of Since 2.12

Meta