[Python-3000] base64 - bytes and strings
"Martin v. Löwis"
martin at v.loewis.de
Mon Jul 30 06:27:13 CEST 2007
> I believe that converting a Unicode string to a base64 encoded form is
> necessarily a 2-step process.
I think that part is undebated. What is the debate is whether
base64.encodestring (which accepts bytes) should *produce*
(unicode) strings, which would then have to be encoded as
us-ascii. That would make a process of going from unicode
to base64 bytes a three-step process:
tosend = base64.encodestring(data.encode("utf-8")).encode("ascii")
Currently, you can spare the last step if you do want bytes,
and need to specify .decode("ascii") if you want strings.
Regards,
Martin
More information about the Python-3000
mailing list