MCPcopy Index your code
hub / github.com/RustPython/RustPython / header_encode

Function header_encode

Lib/email/base64mime.py:59–70  ·  view source on GitHub ↗

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.

(header_bytes, charset='iso-8859-1')

Source from the content-addressed store, hash-verified

57
58
59def header_encode(header_bytes, charset='iso-8859-1'):
60 """Encode a single header line with Base64 encoding in a given charset.
61
62 charset names the character set to use to encode the header. It defaults
63 to iso-8859-1. Base64 encoding is defined in RFC 2045.
64 """
65 if not header_bytes:
66 return ""
67 if isinstance(header_bytes, str):
68 header_bytes = header_bytes.encode(charset)
69 encoded = b64encode(header_bytes).decode("ascii")
70 return '=?%s?b?%s?=' % (charset, encoded)
71
72
73def body_encode(s, maxlinelen=76, eol=NL):

Callers

nothing calls this directly

Calls 4

b64encodeFunction · 0.90
isinstanceFunction · 0.85
encodeMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected