Next: , Previous: , Up: guile-email   [Index]


4 Encoding and Decoding

guile-email supports encoding and decoding using Base64 encoding, Quoted-Printable encoding and Q-encoding. Note that guile-email automatically invokes the necessary decoding procedures while parsing email. The following procedures are only provided in case you need to use them in a context not automatically handled by guile-email.

Character encoding schemes such as UTF-8 encode characters as bytes. Encoding schemes such as Quoted-Printable encoding, Base64 encoding and Q-encoding re-encode these bytes as 7-bit text suitable for transmission over a medium such as email that is not 8-bit clean. Therefore, the input to the following encoding procedures and the output from the following decoding procedures is a bytevector. Encoding characters to bytes or decoding bytes to characters is not within the scope of these procedures. See (guile)Representing Strings as Bytes for more information on how to do this.

4.1 Base64 encoding

(use-modules (email base64))
Scheme Procedure: base64-encode bv

Encode bytevector bv using Base64 encoding and return the encoded string.

Scheme Procedure: base64-decode str

Decode Base64 encoded string str and return the decoded bytevector.

4.2 Quoted-Printable encoding

The Quoted-Printable encoding and decoding procedures in this section are typed functions in that they behave differently based on the types of their arguments.

(use-modules (email quoted-printable))
Scheme Procedure: quoted-printable-encode (bytevector bv)
Scheme Procedure: quoted-printable-encode (port in)
Scheme Procedure: quoted-printable-encode (port in) (port out)

Encode bytevector bv using Quoted-Printable encoding and return the encoded string.

Read bytes from the bytevector input port in and return the Quoted-Printable encoded string.

Read bytes from the bytevector input port in and write the Quoted-Printable encoded string to output port out.

Scheme Procedure: quoted-printable-decode (string str)
Scheme Procedure: quoted-printable-decode (port in)
Scheme Procedure: quoted-printable-decode (port in) (port out)

Decode Quoted-Printable encoded string str and return the decoded bytevector.

Read Quoted-Printable encoded characters from input port in and return the decoded bytevector.

Read Quoted-Printable encoded characters from port in and write the decoded bytevector to bytevector output port out.

4.3 Q-encoding

(use-modules (email quoted-printable))
Scheme Procedure: q-encoding-encode bv

Encode bytevector bv using Q-encoding and return the encoded string.

Scheme Procedure: q-encoding-decode str

Decode Q-encoding encoded string str and return the decoded bytevector.


Next: Reading Email, Previous: Data Types, Up: guile-email   [Index]