EBCDIC <--> ASCII
michael at stroeder.com
Fri Dec 5 15:13:02 CET 2008
martinjamesevans at gmail.com wrote:
> On Dec 4, 4:45 pm, Michael Ströder <mich... at stroeder.com> wrote:
>> martinjamesev... at gmail.com wrote:
>>> I'm having a problem trying to use the codecs package to aid me in
>>> converting some bytes from EBCDIC into ASCII.
>> Which EBCDIC variant?
>>> sEBCDIC = unicode(sSource, 'cp500', 'ignore')
>> Are you sure CP500 is the EBCDIC variant for the language you want?
>> http://www.ietf.org/rfc/rfc1345.txtlists it as:
>> &charset IBM500
>> &rem source: IBM NLS RM Vol2 SE09-8002-01, March 1990
>> &alias CP500
>> &alias ebcdic-cp-be
>> &alias ebcdic-cp-ch
>>> Obviously I could just knock up a 255 character lookup table and do it
>>> myself, I was just trying to be a little more Pythonic and use that
>>> built in table.
>> It's pythonic to implement a Unicode codec for unknown character tables.
>> I've put these two on my web site:
>> http://www.stroeder.com/pylib/encodings/ebcdicatde.pyhttp://www.stroeder.com/pylib/encodings/cp273.py(needs ebcdicatde)
> Thanks for the tables, ebcdicatde.py does look more suitable.
> My problem appears to be that my source is a byte string. In a
> nutshell I need "\x81\x82\x83\xf1\xf2\xf3" to become "abc123" in a
> byte string.
Python 2.5.2 (r252:60911, Aug 1 2008, 00:43:38)
>>> import ebcdicatde
More information about the Python-list