40 std::string
escape(
const std::string &istr)
const
42 typedef unsigned char uchar;
44 std::string str( istr );
45 for (
size_t i = 0; i < str.size(); ++i )
49 case '<': str.replace(i, 1,
"<"); i += 3;
break;
50 case '>': str.replace(i, 1,
">"); i += 3;
break;
51 case '&': str.replace(i, 1,
"&"); i += 4;
break;
52 case '"': str.replace(i, 1,
"""); i += 5;
break;
53 case '\'': str.replace(i, 1,
"'"); i += 5;
break;
62 if ( uchar(str[i]) < 32u )
70 std::string
unescape(
const std::string &istr)
const
73 std::string str = istr;
74 i = str.find_first_of(
"&");
75 while (i != std::string::npos)
79 if (!str.compare(i + 1, 3,
"lt;"))
80 str.replace(i, 4, 1,
'<');
81 else if (!str.compare(i + 1, 3,
"gt;"))
82 str.replace(i, 4, 1,
'>');
83 else if (!str.compare(i + 1, 4,
"amp;"))
84 str.replace(i, 5, 1,
'&');
85 else if (!str.compare(i + 1, 5,
"apos;"))
86 str.replace(i, 6, 1,
'\'');
87 else if (!str.compare(i + 1, 5,
"quot;"))
88 str.replace(i, 6, 1,
'"');
90 i = str.find_first_of(
"&", i + 1);
106 std::string
escape(
const std::string & in_r )
std::string unescape(const std::string &in_r)
Unescape xml special charaters (& -> &; from IoBind library)
std::string escape(const std::string &istr) const
std::string escape(const std::string &in_r)
Escape xml special charaters (& -> &; from IoBind library).
std::string unescape(const std::string &istr) const