Skip to main content

encode_script_quoted_text_to_string

Function encode_script_quoted_text_to_string 

Source
pub fn encode_script_quoted_text_to_string<S: AsRef<str>>(
    text: S,
    output: &mut String,
) -> &str
Expand description

Encode content of a single-quoted or double-quoted JavaScript string to a mutable String and return the new string slice.

This appends to output and returns only the new string slice.

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.