blob: 7de6a663762f0c019422a67bc66a2b29f7ae891b [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001:mod:`binhex` --- Encode and decode binhex4 files
2=================================================
3
4.. module:: binhex
5 :synopsis: Encode and decode files in binhex4 format.
6
Terry Jan Reedyfa089b92016-06-11 15:02:54 -04007**Source code:** :source:`Lib/binhex.py`
8
Victor Stinnerbeea26b2020-01-22 20:44:22 +01009.. deprecated:: 3.9
10
Terry Jan Reedyfa089b92016-06-11 15:02:54 -040011--------------
Georg Brandl116aa622007-08-15 14:28:22 +000012
13This module encodes and decodes files in binhex4 format, a format allowing
Benjamin Peterson69a07fb2008-05-12 22:25:16 +000014representation of Macintosh files in ASCII. Only the data fork is handled.
Georg Brandl116aa622007-08-15 14:28:22 +000015
16The :mod:`binhex` module defines the following functions:
17
18
19.. function:: binhex(input, output)
20
21 Convert a binary file with filename *input* to binhex file *output*. The
22 *output* parameter can either be a filename or a file-like object (any object
23 supporting a :meth:`write` and :meth:`close` method).
24
25
Georg Brandl0d8f0732009-04-05 22:20:44 +000026.. function:: hexbin(input, output)
Georg Brandl116aa622007-08-15 14:28:22 +000027
28 Decode a binhex file *input*. *input* may be a filename or a file-like object
29 supporting :meth:`read` and :meth:`close` methods. The resulting file is written
Georg Brandl0d8f0732009-04-05 22:20:44 +000030 to a file named *output*, unless the argument is ``None`` in which case the
Georg Brandl116aa622007-08-15 14:28:22 +000031 output filename is read from the binhex file.
32
33The following exception is also defined:
34
35
36.. exception:: Error
37
38 Exception raised when something can't be encoded using the binhex format (for
39 example, a filename is too long to fit in the filename field), or when input is
40 not properly encoded binhex data.
41
42
43.. seealso::
44
45 Module :mod:`binascii`
46 Support module containing ASCII-to-binary and binary-to-ASCII conversions.
47
48
49.. _binhex-notes:
50
51Notes
52-----
53
54There is an alternative, more powerful interface to the coder and decoder, see
55the source for details.
56
57If you code or decode textfiles on non-Macintosh platforms they will still use
Georg Brandlc575c902008-09-13 17:46:05 +000058the old Macintosh newline convention (carriage-return as end of line).
Georg Brandl116aa622007-08-15 14:28:22 +000059