def encode(s, charset='iso-8859-1', encoding='q'): """Encode a string according to RFC 2047.""" encoding = encoding.lower() if encoding == 'q': estr = _qencode(s) elif encoding == 'b': estr = _bencode(s) else: raise ValueError, 'Illegal encoding code: ' + encoding return '=?%s?%s?%s?=' % (charset.lower(), encoding, estr)
def encode(s, charset='iso-8859-1', encoding='q'): """Encode a string according to RFC 2047.""" warnings.warn('Use Header.Header.encode() instead.', DeprecationWarning, 2) encoding = encoding.lower() if encoding == 'q': estr = _qencode(s) elif encoding == 'b': estr = _bencode(s) else: raise ValueError, 'Illegal encoding code: ' + encoding return '=?%s?%s?%s?=' % (charset.lower(), encoding, estr)
# Copyright (C) 2001 Python Software Foundation