[Python-3000] base64 - bytes and strings (original) (raw)

Blake Winton bwinton at latte.ca
Mon Jul 30 15:41:21 CEST 2007


Martin v. Löwis wrote:

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.

As a vote for keeping it, does anyone really want to encode the base64-ed data as something other than "ascii"?

I mean, does it make any sense to write: tosend = base64.encodestring(data.encode("utf-8")).encode("UTF-16") ? Even if you could, I believe the resulting string would be un-processable by any other base-64 decoding tool.

Later, Blake.



More information about the Python-3000 mailing list