Add escape/unescape functions

This commit is contained in:
fbraem
2015-12-07 17:31:49 +01:00
parent 2266fc19be
commit 7086d93324
2 changed files with 220 additions and 7 deletions

View File

@@ -54,10 +54,24 @@ struct Foundation_API UTF8
static std::string& toUpperInPlace(std::string& str);
static std::string toLower(const std::string& str);
static std::string& toLowerInPlace(std::string& str);
static void removeBOM(std::string& str);
/// 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);
/// Escapes a string. Special characters like tab, backslash, ... are
/// escaped. Unicode characters are escaped to \uxxxx.
static std::string escape(const std::string::const_iterator& begin, const std::string::const_iterator& end);
/// Escapes a string. Special characters like tab, backslash, ... are
/// escaped. Unicode characters are escaped to \uxxxx.
static std::string unescape(const std::string& s);
/// Creates an UTF8 string from a string that contains escaped characters.
static std::string unescape(const std::string::const_iterator& begin, const std::string::const_iterator& end);
/// Creates an UTF8 string from a string that contains escaped characters.
};