Skip to main content

python_str_repr

Function python_str_repr 

Source
pub fn python_str_repr(s: &str) -> String
Expand description

Python repr() of a string: CPython’s quote selection plus escaping. Single quotes are preferred, switching to double only when the string contains a single quote but no double quote. Backslash, the active quote, and the C0/DEL control characters are escaped; printable Unicode is kept verbatim (matching str.isprintable() for the common ranges).