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

Function _has_surrogates

tools/python-3.11.9-amd64/Lib/email/utils.py:51–60  ·  view source on GitHub ↗

Return True if s may contain surrogate-escaped binary data.

(s)

Source from the content-addressed store, hash-verified

49escapesre = re.compile(r'[\\"]')
50
51def _has_surrogates(s):
52 """Return True if s may contain surrogate-escaped binary data."""
53 # This check is based on the fact that unless there are surrogates, utf8
54 # (Python's default encoding) can encode any string. This is the fastest
55 # way to check for surrogates, see bpo-11454 (moved to gh-55663) for timings.
56 try:
57 s.encode()
58 return False
59 except UnicodeEncodeError:
60 return True
61
62# How to deal with a string containing bytes before handing it to the
63# application through the 'normal' interface.

Callers 5

_foldMethod · 0.90
_sanitize_headerMethod · 0.90
_foldMethod · 0.90
_handle_textMethod · 0.90
_handle_textMethod · 0.90

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected