MCPcopy Create free account
hub / github.com/encounter/objdiff / escape_special_ascii_characters

Function escape_special_ascii_characters

objdiff-core/src/arch/mod.rs:576–590  ·  view source on GitHub ↗

Escape ASCII characters such as \n or \t, but not Unicode characters such as \u{3000}. Suitable for copying to clipboard.

(value: &str)

Source from the content-addressed store, hash-verified

574/// Escape ASCII characters such as \n or \t, but not Unicode characters such as \u{3000}.
575/// Suitable for copying to clipboard.
576fn escape_special_ascii_characters(value: &str) -> String {
577 let mut escaped = String::new();
578 escaped.push('"');
579 for c in value.chars() {
580 if c.is_ascii() {
581 for e in c.escape_default() {
582 escaped.push(e);
583 }
584 } else {
585 escaped.push(c);
586 }
587 }
588 escaped.push('"');
589 escaped
590}

Callers 1

display_literalsMethod · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected