MCPcopy Index your code
hub / github.com/python/cpython / encode_rfc2231

Function encode_rfc2231

Lib/email/utils.py:377–389  ·  view source on GitHub ↗

Encode string according to RFC 2231. If neither charset nor language is given, then s is returned as-is. If charset is given but not language, the string is encoded using the empty string for language.

(s, charset=None, language=None)

Source from the content-addressed store, hash-verified

375
376
377def encode_rfc2231(s, charset=None, language=None):
378 """Encode string according to RFC 2231.
379
380 If neither charset nor language is given, then s is returned as-is. If
381 charset is given but not language, the string is encoded using the empty
382 string for language.
383 """
384 s = urllib.parse.quote(s, safe='', encoding=charset or 'ascii')
385 if charset is None and language is None:
386 return s
387 if language is None:
388 language = ''
389 return "%s'%s'%s" % (charset, language, s)
390
391
392rfc2231_continuation = re.compile(r'^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$',

Callers

nothing calls this directly

Calls 1

quoteMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…