Skip to main content

js_string_escape

Function js_string_escape 

Source
pub fn js_string_escape(string: &str) -> String
Expand description

Escape string so it can be embedded in a JavaScript string literal.

Only ", ', \, \n, \r, U+2028, and U+2029 are escaped; all other characters pass through unchanged.

assert_eq!(js_string_escape("say \"hi\""), "say \\\"hi\\\"");