mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-11-22 04:20:06 +00:00
Merge pull request #230 from arp242/t
Escape control characters in keys
This commit is contained in:
commit
22d96ed921
@ -63,7 +63,19 @@ format_key(const std::basic_string<charT, traits, Alloc>& k)
|
||||
case '\f': {serialized += "\\f"; break;}
|
||||
case '\n': {serialized += "\\n"; break;}
|
||||
case '\r': {serialized += "\\r"; break;}
|
||||
default : {serialized += c; break;}
|
||||
default: {
|
||||
if (c >= 0x00 && c < 0x20)
|
||||
{
|
||||
std::array<char, 7> buf;
|
||||
std::snprintf(buf.data(), buf.size(), "\\u00%02x", static_cast<int>(c));
|
||||
serialized += buf.data();
|
||||
}
|
||||
else
|
||||
{
|
||||
serialized += c;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
serialized += "\"";
|
||||
|
Loading…
Reference in New Issue
Block a user