Skip to main content

encode_script_double_quoted_text

Function encode_script_double_quoted_text 

Source
pub fn encode_script_double_quoted_text<S: ?Sized + AsRef<str>>(
    text: &S,
) -> Cow<'_, str>
Expand description

Encode raw text for a double-quoted JavaScript string inside <script>.

The input is raw text; existing escapes are encoded as text. The output is string content and does not include outer quotes. Backslashes and " are escaped with a backslash. < and C0 controls use \xHH with uppercase hex digits. U+2028 and U+2029 use \u2028 and \u2029. Use the output in a JavaScript string inside <script>, not in a template literal or an HTML attribute.