[Python-3000] base64 - bytes and strings

"Martin v. Löwis" martin at v.loewis.de
Sun Jul 29 06:58:32 CEST 2007


> It seems more natural if the encoded value is a string since
> base64 encoding is a way of encoding data
> so that it fits in US-ASCII.

There have been long debates about this specific question in
the past. The point that proponents of "base64 encoding should
yield strings" miss is that US-ASCII is *both* a character set,
and an encoding. So if data "is in US-ASCII", it's not all that
clear whether the focus is on it being character data, or bytes.

base64 is used "on the wire" most of the time (except when it
gets embedded into XML); from that point of view, it's more
natural that encoding yields bytes.

Regards,
Martin


More information about the Python-3000 mailing list