Skip to main content

escape_all_quotes

Function escape_all_quotes 

Source
pub fn escape_all_quotes<'a, S: Into<Cow<'a, str>>>(input: S) -> Cow<'a, str>
Expand description

Escape a string including both single and double quotes.

Generally, it is safe to leave single quotes (apostrophes) unescaped, so you should use escape_text() or escape_attribute().

use htmlize::escape_all_quotes;

assert!(
    escape_all_quotes("test: &<>\"'é×😀")
        == "test: &amp;&lt;&gt;&quot;&apos;é×😀"
);

To work with bytes ([u8]) instead of strings, see escape_all_quotes_bytes().