format_string

format_string(text: str)

A string as RFC 8785 writes it: only ", \ and control characters escaped.

>>> print(format_string('say "é"\t\x01'))
"say \"é\"\t\u0001"

Raises

Name Type Description
ValueError if text holds a lone surrogate.