From ba78194636a9a498f6979cc21cd39399f23d658a Mon Sep 17 00:00:00 2001 From: kwolekr Date: Sun, 24 Feb 2013 16:00:35 -0500 Subject: Allow any character in formspec strings with escape char --- src/util/string.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/util') diff --git a/src/util/string.h b/src/util/string.h index 2f0264bd4..6c48adeb3 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -286,6 +286,22 @@ inline std::string wrap_rows(const std::string &from, u32 rowlen) return to; } +/* + Removes all \\ from a string that had been escaped (FormSpec strings) +*/ +inline std::string unescape_string(std::string &s) +{ + std::string res; + + for (size_t i = 0; i <= s.length(); i++) { + if (s[i] == '\\') + i++; + res += s[i]; + } + + return res; +} + std::string translatePassword(std::string playername, std::wstring password); size_t curl_write_data(char *ptr, size_t size, size_t nmemb, void *userdata); u32 readFlagString(std::string str, FlagDesc *flagdesc); -- cgit v1.2.3