(header_bytes, charset='iso-8859-1')
return '=?%s?b?%s?=' % (charset, encoded)
Encode a single header line with Base64 encoding in a given charset.

    charset names the character set to use to encode the header.  It defaults
    to iso-8859-1.  Base64 encoding is defined in RFC 2045.
Encode a single header line with Base64 encoding in a given charset.
Encode a single header line with Base64 encoding in a given charset .
def header_encode(header_bytes, charset='iso-8859-1'):
    """Encode a single header line with Base64 encoding in a given charset.

    charset names the character set to use to encode the header.  It defaults
    to iso-8859-1.  Base64 encoding is defined in RFC 2045.
    """
    if not header_bytes:
        return ""
    if isinstance(header_bytes, str):
        header_bytes = header_bytes.encode(charset)
    encoded = b64encode(header_bytes).decode("ascii")
    return '=?%s?b?%s?=' % (charset, encoded)
def header_encode ( header_bytes , charset = 'iso-8859-1' ) : if not header_bytes : return "" if isinstance ( header_bytes , str ) : header_bytes = header_bytes . encode ( charset ) encoded = b64encode ( header_bytes ) . decode ( "ascii" ) return '=?%s?b?%s?=' % ( charset , encoded )