--- smsdaemon/util.cpp 2008/06/10 17:09:33 37 +++ smsdaemon/util.cpp 2008/06/10 20:25:15 38 @@ -2,6 +2,8 @@ #include #include #include +#include + #include #include #include @@ -28,15 +30,42 @@ - void str_clean(string* str, string search, string replace) + string str_replace(string str, string search, string replace) { unsigned int pos = 0; - while ( (pos = str->find(search,pos)) != string::npos) + while ( (pos = str.find(search,pos)) != string::npos) { - str->replace(pos, search.size(), replace); + str.replace(pos, search.size(), replace); pos += replace.size(); } + return str; + } + + + + string str_trim(string str) + { + while (str.length() > 0 && isspace(str.at(0))) + str.erase(0,1); + while (str.length() > 0 && isspace(str.at(str.length()-1))) + str.erase(str.length()-1,1); + return str; + } + + string str_striptags(string str) + { + unsigned int pos=0; + + while ( (pos=str.find("<",pos)) != string::npos) + { + unsigned int endpos = str.find(">",pos); + if (endpos == string::npos) + break; + str.erase(pos, (endpos-pos)+1); + } + + return str; } vector str_split(string input, string delimiter) @@ -61,6 +90,31 @@ return retval; } + string str_characters(string str) + { + string rep; + rep.append(1,197); + str = str_replace(str, "Å", rep); + + rep.at(0) = 198; + str = str_replace(str, "Æ", rep); + + rep.at(0) = 216; + str = str_replace(str, "Ø", rep); + + + rep.at(0) = 229; + str = str_replace(str, "å", rep); + + rep.at(0) = 230; + str = str_replace(str, "æ", rep); + + rep.at(0) = 248; + str = str_replace(str, "ø", rep); + + return str; + } + string readUrl(string url, string tempfile) { char buf[128000];