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

Function needsquoting

Lib/quopri.py:19–32  ·  view source on GitHub ↗

Decide whether a particular byte ordinal needs to be quoted. The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs and spaces are always encoded, as per RFC 1521.

(c, quotetabs, header)

Source from the content-addressed store, hash-verified

17
18
19def needsquoting(c, quotetabs, header):
20 """Decide whether a particular byte ordinal needs to be quoted.
21
22 The 'quotetabs' flag indicates whether embedded tabs and spaces should be
23 quoted. Note that line-ending tabs and spaces are always encoded, as per
24 RFC 1521.
25 """
26 assert isinstance(c, bytes)
27 if c in b' \t':
28 return quotetabs
29 # if header, we have to escape _ because _ is used to escape space
30 if c == b'_':
31 return header
32 return c == ESCAPE or not (b' ' <= c <= b'~')
33
34def quote(c):
35 """Quote a single character."""

Callers 1

encodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…