/Doc/library/quopri.rst

http://unladen-swallow.googlecode.com/ · ReStructuredText · 64 lines · 42 code · 22 blank · 0 comment · 0 complexity · 908c6d3ba0312e0d5024ecb048ccce96 MD5 · raw file

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