I say transliterating, but I really just mean coping with strings involving unprintable characters…
Today I came across a neat little trick which I hope helps you as much as I.
take the following print statement
print "blahÆlec"
this will break
but there are some cases where exact spelling isn’t important you just to to out put the data so you can glace at it, you can actually give the str decode method a nifty argument “ignore” eg.
print "blahÆlec".decode("ascii","ignore")
and this simply drops the unprintable characters.
Success
Peter Ward
December 19, 2012 at 10:15 am
Or, if you have a half-decent terminal emulator, you can just encode it to utf-8, and get the correct character printed instead of mangling the string.
Alec
December 19, 2012 at 11:15 am
This was actually for sanitizing the results of a db2 query to be written to a xlsx spreadsheet and the unicode seemed to kill it