Issue #5262: Improved fix.
[python.git] / Doc / library / binhex.rst
bloba112813ce8cc24ebad29ee3dd524a1990953f7d2
1 :mod:`binhex` --- Encode and decode binhex4 files
2 =================================================
4 .. module:: binhex
5    :synopsis: Encode and decode files in binhex4 format.
8 This module encodes and decodes files in binhex4 format, a format allowing
9 representation of Macintosh files in ASCII.  On the Macintosh, both forks of a
10 file and the finder information are encoded (or decoded), on other platforms
11 only the data fork is handled.
13 .. note::
15    In Python 3.x, special Macintosh support has been removed.
18 The :mod:`binhex` module defines the following functions:
21 .. function:: binhex(input, output)
23    Convert a binary file with filename *input* to binhex file *output*. The
24    *output* parameter can either be a filename or a file-like object (any object
25    supporting a :meth:`write` and :meth:`close` method).
28 .. function:: hexbin(input[, output])
30    Decode a binhex file *input*. *input* may be a filename or a file-like object
31    supporting :meth:`read` and :meth:`close` methods. The resulting file is written
32    to a file named *output*, unless the argument is omitted in which case the
33    output filename is read from the binhex file.
35 The following exception is also defined:
38 .. exception:: Error
40    Exception raised when something can't be encoded using the binhex format (for
41    example, a filename is too long to fit in the filename field), or when input is
42    not properly encoded binhex data.
45 .. seealso::
47    Module :mod:`binascii`
48       Support module containing ASCII-to-binary and binary-to-ASCII conversions.
51 .. _binhex-notes:
53 Notes
54 -----
56 There is an alternative, more powerful interface to the coder and decoder, see
57 the source for details.
59 If you code or decode textfiles on non-Macintosh platforms they will still use
60 the old Macintosh newline convention (carriage-return as end of line).
62 As of this writing, :func:`hexbin` appears to not work in all cases.