Encode control characters with hex not decimal

Fix https://github.com/alexcrichton/toml-rs/issues/178
This commit is contained in:
Alan Du 2017-05-30 23:49:26 +01:00
parent d375f4d63a
commit 90bdb7e96d
3 changed files with 3 additions and 1 deletions

View file

@ -290,7 +290,7 @@ impl<'a> Serializer<'a> {
'\u{22}' => drop(write!(self.dst, "\\\"")),
'\u{5c}' => drop(write!(self.dst, "\\\\")),
c if c < '\u{1f}' => {
drop(write!(self.dst, "\\u{:04}", ch as u32))
drop(write!(self.dst, "\\u{:04X}", ch as u32))
}
ch => drop(write!(self.dst, "{}", ch)),
}

View file

@ -1,4 +1,5 @@
{
"answer1": {"type": "string", "value": "\u000B"},
"answer4": {"type": "string", "value": "\u03B4α"},
"answer8": {"type": "string", "value": "\u03B4β"}
}

View file

@ -1,2 +1,3 @@
answer1 = "\u000B"
answer4 = "\u03B4α"
answer8 = "\U000003B4β"