string Juick encloseHTML string ostr string str str reserve ostr size

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
string Juick::encloseHTML(string ostr) {
string str;
str.reserve(ostr.size());
string::iterator s=ostr.begin(),smax=ostr.end();
while(s!=smax) {
switch(*s) {
case '&': str+="&"; break;
case '<': str+="&lt;"; break;
case '>': str+="&gt;"; break;
default: str+=*s;
}
s++;
}
return str;
}