pub fn substitute(input: &str) -> String {
let mut out = String::new();
let mut escaped = false;
for ch in input.chars() {
if escaped {
match ch {
'n' => out.push('\n'),
't' => out.push('\t'),
c => {
out.push('\\');
out.push(c);
},
}
escaped = false;
}
else {
if ch == '\\' {
escaped = true;
}
else {
out.push(ch);
}
}
}
out
}