Additional EBCDIC codecs
Ebcdic is a Python package adding additional EBCDIC codecs for data exchange with legacy system. It works with Python 2.6+ and Python 3.1+.
EBCDIC is short for Extended Binary Coded Decimal Interchange Code and is a family of character encodings that is mainly used on mainframe computers. There is no real point in using it unless you have to exchange data with legacy systems that still require it. To learn more about EBCDIC, you can start at <https://en.wikipedia.org/wiki/EBCDIC>.
Ebcdic is available from https://pypi.python.org/pypi/ebcdic and can be installed using pip:
pip install ebcdic
To encode ‘hello world’ on EBCDIC systems in German speaking countries, use:
>>> import ebcdic >>> 'hello world'.encode('cp1141') b'\x88\x85\x93\x93\x96@\xa6\x96\x99\x93\x84O'
The ebcdic package includes EBCDIC codecs for the following regions:
It also includes legacy codecs:
Codecs in the standard library overrule some of these codecs. At the time of this writing this concerns cp037, cp273 (since 3.4), cp500 and cp1140.
To see get a list of EBCDIC codecs that are already provided by different sources, use ebcdic.ignored_code_names(). For example, with Python 3.4:
>>> ebcdic.ignored_codec_names() ['cp037', 'cp1140', 'cp273', 'cp500']
These codecs have been generated using CodecMapper available from https://github.com/roskakori/CodecMapper. Read the README in order to to build the ebcdic package from source.
To add another 8 bit EBCDIC codec just extend the ant target ebcdic in build.xml using a line like:
<arg value="cpXXX" />
Copyright (c) 2014, Thomas Aglassinger All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Version 0.7, 2014-11-17
Version 0.6, 2014-11-15
Version 0.5, 2014-11-13