There is str::escape_default
. Is there an inverse for that?
but it has not been updated for 7 years, and unfortunately it's not the perfect inversion for the method.
I have never tested this crate myself, but searching for the “unescape” tag on crates.io brought up
which seems more maintained and AFAICT by glancing at the docs and implementation should/might support everything that str::escape_default
can output.
Nice, this works. The docs say this is the inverse for std::ascii::escape_default
, which does not emit \u{...}
, but this seems supported, so it is also an inverse for std::char::escape_default
(edit: only for char values up to 2^16)
btw, rustc implements this here: rust/unescape.rs at 19c53768af6e48514238e4224b5bf5ecd51bc7b1 · rust-lang/rust · GitHub
Nothing too easy to copy