MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _sanitize

Function _sanitize

tools/python-3.11.9-amd64/Lib/email/utils.py:64–70  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

62# How to deal with a string containing bytes before handing it to the
63# application through the 'normal' interface.
64def _sanitize(string):
65 # Turn any escaped bytes into unicode 'unknown' char. If the escaped
66 # bytes happen to be utf-8 they will instead get decoded, even if they
67 # were invalid in the charset the source was supposed to be in. This
68 # seems like it is not a bad thing; a defect was still registered.
69 original_bytes = string.encode('utf-8', 'surrogateescape')
70 return original_bytes.decode('utf-8', 'replace')
71
72
73

Callers

nothing calls this directly

Calls 2

encodeMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected