Read and Print ASCII >128 as is in cp437 on DOT-MATRIX printer or file regardless local setting
Walter Dörwald
walter at livinglogic.de
Thu Dec 13 10:59:40 EST 2001
Sjoerd Mullender wrote:
> [...]
> So, an alternative which will ignore all unconvertible characters is:
>
> result = []
> for c in unicode(data, 'cp437'):
> try:
> result.append(c.encode('iso-8859-2')) # or 'us-ascii', or ...
> except:
> pass
> print ''.join(result)
This can be done much simpler:
print unicode(data, 'cp437').encode('iso-8859-2', "ignore")
Bye,
Walter Dörwald
More information about the Python-list
mailing list