1:mod:`quopri` --- Encode and decode MIME quoted-printable data 2============================================================== 3 4.. module:: quopri 5 :synopsis: Encode and decode files using the MIME quoted-printable encoding. 6 7 8.. index:: 9 pair: quoted-printable; encoding 10 single: MIME; quoted-printable encoding 11 12**Source code:** :source:`Lib/quopri.py` 13 14-------------- 15 16This module performs quoted-printable transport encoding and decoding, as 17defined in :rfc:`1521`: "MIME (Multipurpose Internet Mail Extensions) Part One: 18Mechanisms for Specifying and Describing the Format of Internet Message Bodies". 19The quoted-printable encoding is designed for data where there are relatively 20few nonprintable characters; the base64 encoding scheme available via the 21:mod:`base64` module is more compact if there are many such characters, as when 22sending a graphics file. 23 24.. function:: decode(input, output[,header]) 25 26 Decode the contents of the *input* file and write the resulting decoded binary 27 data to the *output* file. *input* and *output* must either be file objects or 28 objects that mimic the file object interface. *input* will be read until 29 ``input.readline()`` returns an empty string. If the optional argument *header* 30 is present and true, underscore will be decoded as space. This is used to decode 31 "Q"-encoded headers as described in :rfc:`1522`: "MIME (Multipurpose Internet 32 Mail Extensions) Part Two: Message Header Extensions for Non-ASCII Text". 33 34 35.. function:: encode(input, output, quotetabs) 36 37 Encode the contents of the *input* file and write the resulting quoted-printable 38 data to the *output* file. *input* and *output* must either be file objects or 39 objects that mimic the file object interface. *input* will be read until 40 ``input.readline()`` returns an empty string. *quotetabs* is a flag which 41 controls whether to encode embedded spaces and tabs; when true it encodes such 42 embedded whitespace, and when false it leaves them unencoded. Note that spaces 43 and tabs appearing at the end of lines are always encoded, as per :rfc:`1521`. 44 45 46.. function:: decodestring(s[,header]) 47 48 Like :func:`decode`, except that it accepts a source string and returns the 49 corresponding decoded string. 50 51 52.. function:: encodestring(s[, quotetabs]) 53 54 Like :func:`encode`, except that it accepts a source string and returns the 55 corresponding encoded string. *quotetabs* is optional (defaulting to 0), and is 56 passed straight through to :func:`encode`. 57 58 59.. seealso:: 60 61 Module :mod:`mimify` 62 General utilities for processing of MIME messages. 63 64 Module :mod:`base64` 65 Encode and decode MIME base64 data 66 67