blob: 9e5a8f324447de0b0df65d1bcc756bac67b47dfb [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001
2:mod:`binhex` --- Encode and decode binhex4 files
3=================================================
4
5.. module:: binhex
6 :synopsis: Encode and decode files in binhex4 format.
7
8
9This module encodes and decodes files in binhex4 format, a format allowing
Benjamin Peterson69a07fb2008-05-12 22:25:16 +000010representation of Macintosh files in ASCII. Only the data fork is handled.
Georg Brandl116aa622007-08-15 14:28:22 +000011
12The :mod:`binhex` module defines the following functions:
13
14
15.. function:: binhex(input, output)
16
17 Convert a binary file with filename *input* to binhex file *output*. The
18 *output* parameter can either be a filename or a file-like object (any object
19 supporting a :meth:`write` and :meth:`close` method).
20
21
22.. function:: hexbin(input[, output])
23
24 Decode a binhex file *input*. *input* may be a filename or a file-like object
25 supporting :meth:`read` and :meth:`close` methods. The resulting file is written
26 to a file named *output*, unless the argument is omitted in which case the
27 output filename is read from the binhex file.
28
29The following exception is also defined:
30
31
32.. exception:: Error
33
34 Exception raised when something can't be encoded using the binhex format (for
35 example, a filename is too long to fit in the filename field), or when input is
36 not properly encoded binhex data.
37
38
39.. seealso::
40
41 Module :mod:`binascii`
42 Support module containing ASCII-to-binary and binary-to-ASCII conversions.
43
44
45.. _binhex-notes:
46
47Notes
48-----
49
50There is an alternative, more powerful interface to the coder and decoder, see
51the source for details.
52
53If you code or decode textfiles on non-Macintosh platforms they will still use
54the Macintosh newline convention (carriage-return as end of line).
55
56As of this writing, :func:`hexbin` appears to not work in all cases.
57