MCPcopy Index your code
hub / github.com/JoshData/python-email-validator / safe_character_display

Function safe_character_display

email_validator/syntax.py:208–222  ·  view source on GitHub ↗
(c: str)

Source from the content-addressed store, hash-verified

206
207
208def 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
225class LocalPartValidationResult(TypedDict):

Callers 6

unquote_quoted_stringFunction · 0.85
split_emailFunction · 0.85
check_unsafe_charsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected