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

Function _encode

Lib/email/charset.py:155–159  ·  view source on GitHub ↗
(string, codec)

Source from the content-addressed store, hash-verified

153# Convenience function for encoding strings, taking into account
154# that they might be unknown-8bit (ie: have surrogate-escaped bytes)
155def _encode(string, codec):
156 if codec == UNKNOWN8BIT:
157 return string.encode('ascii', 'surrogateescape')
158 else:
159 return string.encode(codec)
160
161
162class Charset:

Callers 2

header_encodeMethod · 0.70
header_encode_linesMethod · 0.70

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…