Quote a single character.
(c)
| 32 | return c == ESCAPE or not (b' ' <= c <= b'~') |
| 33 | |
| 34 | def quote(c): |
| 35 | """Quote a single character.""" |
| 36 | assert isinstance(c, bytes) and len(c)==1 |
| 37 | c = ord(c) |
| 38 | return ESCAPE + bytes((HEX[c//16], HEX[c%16])) |
| 39 | |
| 40 | |
| 41 |