Skip to content

Commit

Permalink
Do not escape chars as unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
999eagle committed Jun 20, 2019
1 parent 2b6787c commit d072e8d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,11 +637,15 @@ fn escape_string(string: &str) -> String {
// In quoted RC strings, double-quotes are escaped by using two
// consecutive double-quotes. Other characters are escaped in the
// usual C way using backslashes.
if chr == '"' {
escaped.push_str("\"\"");
} else {
escaped.extend(chr.escape_default());
}
match chr {
'"' => escaped.push_str("\"\""),
'\'' => escaped.push_str("\\'"),
'\\' => escaped.push_str("\\\\"),
'\n' => escaped.push_str("\\n"),
'\t' => escaped.push_str("\\t"),
'\r' => escaped.push_str("\\r"),
_ => escaped.push(chr),
};
}
escaped
}
Expand Down

0 comments on commit d072e8d

Please sign in to comment.