| 1584 | } |
| 1585 | |
| 1586 | String Utility::UnescapeString(const String& s) |
| 1587 | { |
| 1588 | std::ostringstream result; |
| 1589 | |
| 1590 | for (String::SizeType i = 0; i < s.GetLength(); i++) { |
| 1591 | if (s[i] == '%') { |
| 1592 | if (i + 2 > s.GetLength() - 1) |
| 1593 | BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid escape sequence.")); |
| 1594 | |
| 1595 | char ch = HexDecode(s[i + 1]) * 16 + HexDecode(s[i + 2]); |
| 1596 | result << ch; |
| 1597 | |
| 1598 | i += 2; |
| 1599 | } else |
| 1600 | result << s[i]; |
| 1601 | } |
| 1602 | |
| 1603 | return result.str(); |
| 1604 | } |
| 1605 | |
| 1606 | #ifndef _WIN32 |
| 1607 | static String UnameHelper(char type) |