7bit to 8bit

Mark Rowe bdash at gmx.net
Wed Apr 14 23:44:19 EDT 2004


On 15/04/2004, at 15:05, Daniel Roth wrote:

> how do one easy convert a 8bit-text, which by python seems to be in 
> 7bit, to 8bit? I want to convert '=F6' to 'ö', '=E4' to 'ä' and so on.
> of course without doing a replace for all those characters.

Strings containing sequences like '=F6' appear to have be latin-1 
strings that have been encoding using the "quoted printable" encoding.  
The following snippet shows one method of decoding the data:

 >>> print "=F6=E4".decode('quopri').decode('latin-1')
öä

Alternatively, you should look into the quopri module and it's 
decodestring function.

Hope this helps,

Mark Rowe
http://bdash.bluewire.net.nz
  




More information about the Python-list mailing list