Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 1 | |
| 2 | :mod:`binhex` --- Encode and decode binhex4 files |
| 3 | ================================================= |
| 4 | |
| 5 | .. module:: binhex |
| 6 | :synopsis: Encode and decode files in binhex4 format. |
| 7 | |
| 8 | |
| 9 | This module encodes and decodes files in binhex4 format, a format allowing |
| 10 | representation of Macintosh files in ASCII. On the Macintosh, both forks of a |
| 11 | file and the finder information are encoded (or decoded), on other platforms |
| 12 | only the data fork is handled. |
| 13 | |
Benjamin Peterson | 2368193 | 2008-05-12 21:42:13 +0000 | [diff] [blame] | 14 | .. warning:: |
| 15 | |
| 16 | In 3.0, special Macintosh support is removed. |
| 17 | |
| 18 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 19 | The :mod:`binhex` module defines the following functions: |
| 20 | |
| 21 | |
| 22 | .. function:: binhex(input, output) |
| 23 | |
| 24 | Convert a binary file with filename *input* to binhex file *output*. The |
| 25 | *output* parameter can either be a filename or a file-like object (any object |
| 26 | supporting a :meth:`write` and :meth:`close` method). |
| 27 | |
| 28 | |
| 29 | .. function:: hexbin(input[, output]) |
| 30 | |
| 31 | Decode a binhex file *input*. *input* may be a filename or a file-like object |
| 32 | supporting :meth:`read` and :meth:`close` methods. The resulting file is written |
| 33 | to a file named *output*, unless the argument is omitted in which case the |
| 34 | output filename is read from the binhex file. |
| 35 | |
| 36 | The following exception is also defined: |
| 37 | |
| 38 | |
| 39 | .. exception:: Error |
| 40 | |
| 41 | Exception raised when something can't be encoded using the binhex format (for |
| 42 | example, a filename is too long to fit in the filename field), or when input is |
| 43 | not properly encoded binhex data. |
| 44 | |
| 45 | |
| 46 | .. seealso:: |
| 47 | |
| 48 | Module :mod:`binascii` |
| 49 | Support module containing ASCII-to-binary and binary-to-ASCII conversions. |
| 50 | |
| 51 | |
| 52 | .. _binhex-notes: |
| 53 | |
| 54 | Notes |
| 55 | ----- |
| 56 | |
| 57 | There is an alternative, more powerful interface to the coder and decoder, see |
| 58 | the source for details. |
| 59 | |
| 60 | 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^] | 61 | the old Macintosh newline convention (carriage-return as end of line). |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 62 | |
| 63 | As of this writing, :func:`hexbin` appears to not work in all cases. |
| 64 | |