Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 1 | :mod:`binhex` --- Encode and decode binhex4 files |
| 2 | ================================================= |
| 3 | |
| 4 | .. module:: binhex |
| 5 | :synopsis: Encode and decode files in binhex4 format. |
| 6 | |
| 7 | |
| 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. |
| 12 | |
Georg Brandl | b44c9f3 | 2009-04-27 15:29:26 +0000 | [diff] [blame] | 13 | .. note:: |
Benjamin Peterson | 2368193 | 2008-05-12 21:42:13 +0000 | [diff] [blame] | 14 | |
Georg Brandl | b44c9f3 | 2009-04-27 15:29:26 +0000 | [diff] [blame] | 15 | In Python 3.x, special Macintosh support has been removed. |
Benjamin Peterson | 2368193 | 2008-05-12 21:42:13 +0000 | [diff] [blame] | 16 | |
| 17 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 18 | The :mod:`binhex` module defines the following functions: |
| 19 | |
| 20 | |
| 21 | .. function:: binhex(input, output) |
| 22 | |
| 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). |
| 26 | |
| 27 | |
| 28 | .. function:: hexbin(input[, output]) |
| 29 | |
| 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. |
| 34 | |
| 35 | The following exception is also defined: |
| 36 | |
| 37 | |
| 38 | .. exception:: Error |
| 39 | |
| 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. |
| 43 | |
| 44 | |
| 45 | .. seealso:: |
| 46 | |
| 47 | Module :mod:`binascii` |
| 48 | Support module containing ASCII-to-binary and binary-to-ASCII conversions. |
| 49 | |
| 50 | |
| 51 | .. _binhex-notes: |
| 52 | |
| 53 | Notes |
| 54 | ----- |
| 55 | |
| 56 | There is an alternative, more powerful interface to the coder and decoder, see |
| 57 | the source for details. |
| 58 | |
| 59 | If you code or decode textfiles on non-Macintosh platforms they will still use |
Georg Brandl | 9af9498 | 2008-09-13 17:41:16 +0000 | [diff] [blame] | 60 | the old Macintosh newline convention (carriage-return as end of line). |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 61 | |
| 62 | As of this writing, :func:`hexbin` appears to not work in all cases. |
| 63 | |