# Copyright (C) 2001-2006 Python Software Foundation
# Contact: email-sig@python.org
"""Encodings and related functions."""
from quopri import encodestring as _encodestring
enc = _encodestring(s, quotetabs=True)
# Must encode spaces, which quopri.encodestring() doesn't do
return enc.replace(' ', '=20')
# We can't quite use base64.encodestring() since it tacks on a "courtesy
hasnewline = (s[-1] == '\n')
value = base64.encodestring(s)
if not hasnewline and value[-1] == '\n':
"""Encode the message's payload in Base64.
Also, add an appropriate Content-Transfer-Encoding header.