+ * @param out Output, must not be the same string as str
+ * @return True if the string was unescaped, false if an invalid escape sequence is present in the input in which case out will contain a partially unescaped string
+ for (std::string::const_iterator i = str.begin(); i != str.end(); ++i)
+ {
+ char c = *i;
+ if (c == '\\')
+ {
+ ++i;
+ if (i == str.end())
+ return false;
+
+ char nextc = *i;
+ if (nextc == esc)
+ c = esc;
+ else if (nextc != to)
+ return false; // Invalid escape sequence
+ else
+ c = from;
+ }
+ out.push_back(c);
+ }
+ return true;
+ }
+
+ /**
+ * Unescape a string using the backslash character as the escape character
+ * @param str String to unescape
+ * @param out Output, must not be the same string as str
+ * @return True if the string was unescaped, false if an invalid escape sequence is present in the input in which case out will contain a partially unescaped string