For Gauche 0.9.5


Next: , Previous: , Up: Library modules - Utilities   [Contents][Index]

12.29 rfc.base64 - Base64 encoding/decoding

Module: rfc.base64

This module defines a few functions to encode/decode Base64 format, defined in RFC 2045 (RFC2045), section 6.3 and RFC 4648 (RFC4648)

Function: base64-encode :key line-width url-safe

Reads byte stream from the current input port, encodes it in Base64 format and writes the result character stream to the current output port. The conversion ends when it reads EOF from the current input port.

Newline characters can be inserted to keep the maximum line width to the value given to the line-width keyword argument. The default value of line-width is 76, as specified in RFC2045. You can give #f or zero to line-width to suppress line splitting.

If a true value is given to url-safe, the input bytes will be encoded with an alternative encoding table, which substitutes + instead of - and / instead of _. The result will contain filename and url safe characters only. Default value of url-safe is false.

Function: base64-encode-string string :key line-width url-safe

Converts contents of string to Base64 encoded format. Input string can be either complete or incomplete string; it is always interpreted as a byte sequence.

Function: base64-decode :key url-safe

Reads character stream from the current input port, decodes it from Base64 format and writes the result byte stream to the current output port. The conversion ends when it reads EOF or the termination character (=). The characters which does not in legal Base64 encoded character set are silently ignored.

Function: base64-decode-string string :key url-safe

Decodes a Base64 encoded string string and returns the result as a string. The conversion terminates at the end of string or the termination character (=). The characters which does not in legal Base64 encoded character set are silently ignored.


Next: , Previous: , Up: Library modules - Utilities   [Contents][Index]