/[projects]/smsdaemon/Util.cpp
ViewVC logotype

Diff of /smsdaemon/Util.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 26 by torben, Mon Jun 9 18:15:53 2008 UTC revision 38 by torben, Tue Jun 10 20:25:15 2008 UTC
# Line 2  Line 2 
2  #include <string>  #include <string>
3  #include <sstream>  #include <sstream>
4  #include <vector>  #include <vector>
5    #include <cctype>
6    
7  #include <iostream>  #include <iostream>
8  #include <fstream>  #include <fstream>
9  #include <iconv.h>  #include <iconv.h>
# Line 28  namespace Util Line 30  namespace Util
30    
31    
32    
33          void str_clean(string* str, string search, string replace)          string str_replace(string str, string search, string replace)
34          {          {
35                  unsigned int pos = 0;                  unsigned int pos = 0;
36                                    
37                  while ( (pos = str->find(search,pos)) != string::npos)                  while ( (pos = str.find(search,pos)) != string::npos)
38                  {                  {
39                          str->replace(pos, search.size(), replace);                          str.replace(pos, search.size(), replace);
40                          pos += replace.size();                          pos += replace.size();
41                  }                  }
42                    return str;
43            }
44    
45            
46    
47            string str_trim(string str)
48            {
49                    while (str.length() > 0 && isspace(str.at(0)))
50                            str.erase(0,1);
51                    while (str.length() > 0 && isspace(str.at(str.length()-1)))
52                            str.erase(str.length()-1,1);
53                    return str;
54            }
55    
56            string str_striptags(string str)
57            {
58                    unsigned int pos=0;
59    
60                    while ( (pos=str.find("<",pos)) != string::npos)
61                    {
62                            unsigned int endpos = str.find(">",pos);
63                            if (endpos == string::npos)
64                                    break;
65                            str.erase(pos, (endpos-pos)+1);
66                    }
67    
68                    return str;
69          }          }
70    
71          vector<string> str_split(string input, string delimiter)          vector<string> str_split(string input, string delimiter)
# Line 61  namespace Util Line 90  namespace Util
90                  return retval;                  return retval;
91          }          }
92    
93            string str_characters(string str)
94            {
95                    string rep;
96                    rep.append(1,197);
97                    str = str_replace(str, "&#197;", rep);
98    
99                    rep.at(0) = 198;
100                    str = str_replace(str, "&#198;", rep);
101    
102                    rep.at(0) = 216;
103                    str = str_replace(str, "&#216;", rep);
104    
105    
106                    rep.at(0) = 229;
107                    str = str_replace(str, "&#229;", rep);
108    
109                    rep.at(0) = 230;
110                    str = str_replace(str, "&#230;", rep);
111    
112                    rep.at(0) = 248;
113                    str = str_replace(str, "&#248;", rep);
114    
115                    return str;
116            }
117    
118          string readUrl(string url, string tempfile)          string readUrl(string url, string tempfile)
119          {          {
120                  char buf[128000];                  char buf[128000];

Legend:
Removed from v.26  
changed lines
  Added in v.38

  ViewVC Help
Powered by ViewVC 1.1.20