| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="lib.html" title='Python Library Reference' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="next" href="module-quopri.html" /> |
| 13 | <link rel="prev" href="module-binascii.html" /> |
| 14 | <link rel="parent" href="netdata.html" /> |
| 15 | <link rel="next" href="binhex-notes.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>12.14 binhex -- Encode and decode binhex4 files</title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="12.13 binascii " |
| 25 | href="module-binascii.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="12. Internet Data Handling" |
| 28 | href="netdata.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="12.14.1 Notes" |
| 31 | href="binhex-notes.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Python Library Reference</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 38 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 39 | <td class='online-navigation'><a rel="index" title="Index" |
| 40 | href="genindex.html"><img src='../icons/index.png' |
| 41 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 42 | </tr></table> |
| 43 | <div class='online-navigation'> |
| 44 | <b class="navlabel">Previous:</b> |
| 45 | <a class="sectref" rel="prev" href="module-binascii.html">12.13 binascii </A> |
| 46 | <b class="navlabel">Up:</b> |
| 47 | <a class="sectref" rel="parent" href="netdata.html">12. Internet Data Handling</A> |
| 48 | <b class="navlabel">Next:</b> |
| 49 | <a class="sectref" rel="next" href="binhex-notes.html">12.14.1 Notes</A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H1><A NAME="SECTION00141400000000000000000"> |
| 56 | 12.14 <tt class="module">binhex</tt> -- |
| 57 | Encode and decode binhex4 files</A> |
| 58 | </H1> |
| 59 | |
| 60 | <P> |
| 61 | <A NAME="module-binhex"></A> |
| 62 | |
| 63 | <P> |
| 64 | This module encodes and decodes files in binhex4 format, a format |
| 65 | allowing representation of Macintosh files in ASCII. On the Macintosh, |
| 66 | both forks of a file and the finder information are encoded (or |
| 67 | decoded), on other platforms only the data fork is handled. |
| 68 | |
| 69 | <P> |
| 70 | The <tt class="module">binhex</tt> module defines the following functions: |
| 71 | |
| 72 | <P> |
| 73 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 74 | <td><nobr><b><tt id='l2h-4146' xml:id='l2h-4146' class="function">binhex</tt></b>(</nobr></td> |
| 75 | <td><var>input, output</var>)</td></tr></table></dt> |
| 76 | <dd> |
| 77 | Convert a binary file with filename <var>input</var> to binhex file |
| 78 | <var>output</var>. The <var>output</var> parameter can either be a filename or a |
| 79 | file-like object (any object supporting a <tt class="method">write()</tt> and |
| 80 | <tt class="method">close()</tt> method). |
| 81 | </dl> |
| 82 | |
| 83 | <P> |
| 84 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 85 | <td><nobr><b><tt id='l2h-4147' xml:id='l2h-4147' class="function">hexbin</tt></b>(</nobr></td> |
| 86 | <td><var>input</var><big>[</big><var>, output</var><big>]</big><var></var>)</td></tr></table></dt> |
| 87 | <dd> |
| 88 | Decode a binhex file <var>input</var>. <var>input</var> may be a filename or a |
| 89 | file-like object supporting <tt class="method">read()</tt> and <tt class="method">close()</tt> methods. |
| 90 | The resulting file is written to a file named <var>output</var>, unless the |
| 91 | argument is omitted in which case the output filename is read from the |
| 92 | binhex file. |
| 93 | </dl> |
| 94 | |
| 95 | <P> |
| 96 | The following exception is also defined: |
| 97 | |
| 98 | <P> |
| 99 | <dl><dt><b><span class="typelabel">exception</span> <tt id='l2h-4148' xml:id='l2h-4148' class="exception">Error</tt></b></dt> |
| 100 | <dd> |
| 101 | Exception raised when something can't be encoded using the binhex |
| 102 | format (for example, a filename is too long to fit in the filename |
| 103 | field), or when input is not properly encoded binhex data. |
| 104 | </dd></dl> |
| 105 | |
| 106 | <P> |
| 107 | <div class="seealso"> |
| 108 | <p class="heading">See Also:</p> |
| 109 | |
| 110 | <dl compact="compact" class="seemodule"> |
| 111 | <dt>Module <b><tt class="module"><a href="module-binascii.html">binascii</a></tt>:</b> |
| 112 | <dd>Support module containing ASCII-to-binary |
| 113 | and binary-to-ASCII conversions. |
| 114 | </dl> |
| 115 | </div> |
| 116 | |
| 117 | <P> |
| 118 | |
| 119 | <p><br /></p><hr class='online-navigation' /> |
| 120 | <div class='online-navigation'> |
| 121 | <!--Table of Child-Links--> |
| 122 | <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a> |
| 123 | |
| 124 | <UL CLASS="ChildLinks"> |
| 125 | <LI><A href="binhex-notes.html">12.14.1 Notes</a> |
| 126 | </ul> |
| 127 | <!--End of Table of Child-Links--> |
| 128 | </div> |
| 129 | |
| 130 | <DIV CLASS="navigation"> |
| 131 | <div class='online-navigation'> |
| 132 | <p></p><hr /> |
| 133 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 134 | <tr> |
| 135 | <td class='online-navigation'><a rel="prev" title="12.13 binascii " |
| 136 | href="module-binascii.html"><img src='../icons/previous.png' |
| 137 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 138 | <td class='online-navigation'><a rel="parent" title="12. Internet Data Handling" |
| 139 | href="netdata.html"><img src='../icons/up.png' |
| 140 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 141 | <td class='online-navigation'><a rel="next" title="12.14.1 Notes" |
| 142 | href="binhex-notes.html"><img src='../icons/next.png' |
| 143 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 144 | <td align="center" width="100%">Python Library Reference</td> |
| 145 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 146 | href="contents.html"><img src='../icons/contents.png' |
| 147 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 148 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 149 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 150 | <td class='online-navigation'><a rel="index" title="Index" |
| 151 | href="genindex.html"><img src='../icons/index.png' |
| 152 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 153 | </tr></table> |
| 154 | <div class='online-navigation'> |
| 155 | <b class="navlabel">Previous:</b> |
| 156 | <a class="sectref" rel="prev" href="module-binascii.html">12.13 binascii </A> |
| 157 | <b class="navlabel">Up:</b> |
| 158 | <a class="sectref" rel="parent" href="netdata.html">12. Internet Data Handling</A> |
| 159 | <b class="navlabel">Next:</b> |
| 160 | <a class="sectref" rel="next" href="binhex-notes.html">12.14.1 Notes</A> |
| 161 | </div> |
| 162 | </div> |
| 163 | <hr /> |
| 164 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 165 | </DIV> |
| 166 | <!--End of Navigation Panel--> |
| 167 | <ADDRESS> |
| 168 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 169 | </ADDRESS> |
| 170 | </BODY> |
| 171 | </HTML> |