Skip to main content

luaur_analysis/functions/
dot_escape.rs

1use alloc::string::String;
2use core::fmt::Write;
3
4pub fn dot_escape(os: &mut String, s: &str) {
5    os.push('"');
6    for c in s.chars() {
7        match c {
8            '"' => os.push_str("\\\""),
9            '\\' => os.push_str("\\\\"),
10            '\n' => os.push_str("\\n"),
11            '<' => os.push_str("\\<"),
12            '>' => os.push_str("\\>"),
13            '{' => os.push_str("\\{"),
14            '}' => os.push_str("\\}"),
15            '|' => os.push_str("\\|"),
16            _ => os.push(c),
17        }
18    }
19    os.push('"');
20}