Popular recipes tagged "encoding" but not "encode"http://code.activestate.com/recipes/tags/encoding-encode/2016-07-23T07:58:14-07:00ActiveState Code RecipesHamming Error Correction Code (Python) 2016-07-23T07:58:14-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/580691-hamming-error-correction-code/ <p style="color: grey"> Python recipe 580691 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/encoding/">encoding</a>, <a href="/recipes/tags/engineering/">engineering</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/utility/">utility</a>). </p> <p>Hamming(7,4) Error Correction Code (ECC).</p> De-chunk and decompress HTTP body (Python) 2015-06-30T03:31:31-07:00Vovanhttp://code.activestate.com/recipes/users/4192447/http://code.activestate.com/recipes/579075-de-chunk-and-decompress-http-body/ <p style="color: grey"> Python recipe 579075 by <a href="/recipes/users/4192447/">Vovan</a> (<a href="/recipes/tags/chunked/">chunked</a>, <a href="/recipes/tags/content/">content</a>, <a href="/recipes/tags/dechunking/">dechunking</a>, <a href="/recipes/tags/decompression/">decompression</a>, <a href="/recipes/tags/encoding/">encoding</a>, <a href="/recipes/tags/http/">http</a>, <a href="/recipes/tags/preprocess/">preprocess</a>, <a href="/recipes/tags/transfer/">transfer</a>). Revision 2. </p> <p>Example read_body_stream() usage:</p> <pre class="prettyprint"><code>with open(http_file_path, 'rb') as fh: print(b''.join(httputil.read_body_stream( fh, chunked=True, compression=httputil.GZIP)) </code></pre> Mazovia encoding for Polish text from MS-DOS era (Python) 2012-02-15T09:24:13-08:00Michal Niklashttp://code.activestate.com/recipes/users/186902/http://code.activestate.com/recipes/578040-mazovia-encoding-for-polish-text-from-ms-dos-era/ <p style="color: grey"> Python recipe 578040 by <a href="/recipes/users/186902/">Michal Niklas</a> (<a href="/recipes/tags/encoding/">encoding</a>, <a href="/recipes/tags/mazovia/">mazovia</a>, <a href="/recipes/tags/polish/">polish</a>). </p> <p>Some MS-DOS era text or databases in Poland use Mazovia encoding for letters such as: ą, ę, ś, ż, ź. It is very well described on Polish wikipedia: <a href="http://pl.wikipedia.org/wiki/Mazovia_%28kod%29" rel="nofollow">http://pl.wikipedia.org/wiki/Mazovia_(kod)</a></p> <p>There is <code>mazovia.py</code> with Polish encoding. Copy it to the Python <code>Lib/encodings</code> directory. Tested with Python 2.7. For Python 3.2 I had to remove unicode string u prefix.</p> <p>Usage:</p> <pre class="prettyprint"><code>def conv_file(fname): f = codecs.open(fname, 'rb', 'mazovia') s = f.read() f.close() f = codecs.open(fname + '_utf8', 'wb', 'utf8') f.write(s) f.close() </code></pre>