Checks whether `chars` is a control character.
(char)
| 368 | |
| 369 | |
| 370 | def _is_control(char): |
| 371 | """Checks whether `chars` is a control character.""" |
| 372 | # These are technically control characters but we count them as whitespace |
| 373 | # characters. |
| 374 | if char == "\t" or char == "\n" or char == "\r": |
| 375 | return False |
| 376 | cat = unicodedata.category(char) |
| 377 | if cat in ("Cc", "Cf"): |
| 378 | return True |
| 379 | return False |
| 380 | |
| 381 | |
| 382 | def _is_punctuation(char): |