(c: str)
| 206 | |
| 207 | |
| 208 | def safe_character_display(c: str) -> str: |
| 209 | # Return safely displayable characters in quotes. |
| 210 | if c == '\\': |
| 211 | return f"\"{c}\"" # can't use repr because it escapes it |
| 212 | if unicodedata.category(c)[0] in ("L", "N", "P", "S"): |
| 213 | return repr(c) |
| 214 | |
| 215 | # Construct a hex string in case the unicode name doesn't exist. |
| 216 | if ord(c) < 0xFFFF: |
| 217 | h = f"U+{ord(c):04x}".upper() |
| 218 | else: |
| 219 | h = f"U+{ord(c):08x}".upper() |
| 220 | |
| 221 | # Return the character name or, if it has no name, the hex string. |
| 222 | return unicodedata.name(c, h) |
| 223 | |
| 224 | |
| 225 | class LocalPartValidationResult(TypedDict): |
no outgoing calls
no test coverage detected