Stricter JSON standard conformance (#2153)

This commit is contained in:
Conor Burgess
2018-02-13 13:15:53 +00:00
committed by Alex Fabijanic
parent bdd0478ead
commit 2632f34e85
8 changed files with 61 additions and 13 deletions

View File

@@ -57,13 +57,17 @@ struct Foundation_API UTF8
/// Remove the UTF-8 Byte Order Mark sequence (0xEF, 0xBB, 0xBF)
/// from the beginning of the string, if it's there.
static std::string escape(const std::string& s);
static std::string escape(const std::string& s, bool strictJSON = false);
/// Escapes a string. Special characters like tab, backslash, ... are
/// escaped. Unicode characters are escaped to \uxxxx.
/// If strictJSON is true, \a and \v will be escaped to \\u0007 and \\u000B
/// instead of \\a and \\v for strict JSON conformance.
static std::string escape(const std::string::const_iterator& begin, const std::string::const_iterator& end);
static std::string escape(const std::string::const_iterator& begin, const std::string::const_iterator& end, bool strictJSON = false);
/// Escapes a string. Special characters like tab, backslash, ... are
/// escaped. Unicode characters are escaped to \uxxxx.
/// If strictJSON is true, \a and \v will be escaped to \\u0007 and \\u000B
/// instead of \\a and \\v for strict JSON conformance.
static std::string unescape(const std::string& s);
/// Creates an UTF8 string from a string that contains escaped characters.