[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: iso8859 -> utf8 -> base64 code?
Christian Nygaard wrote:
Hi can somebody please post working iso8859 -> utf8 -> base64
Perl/Python conversion code?
Assuming Python 2.0 or newer:
# Import base64 module
import base64
# raw string with ISO-8859-1 chars
s='Michael Str\xf6der'
# Create Unicode object from s with known charset/encoding
u=unicode(s,'iso-8859-1')
# Copy UTF-8 encoding to raw string
s_utf8=u.encode('utf-8')
# base64-encode the raw string into new raw string b
b=base64.encodestring(s_utf8)
Ciao, Michael.