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> |
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) |
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, "Å", rep); |
98 |
|
|
99 |
|
rep.at(0) = 198; |
100 |
|
str = str_replace(str, "Æ", rep); |
101 |
|
|
102 |
|
rep.at(0) = 216; |
103 |
|
str = str_replace(str, "Ø", rep); |
104 |
|
|
105 |
|
|
106 |
|
rep.at(0) = 229; |
107 |
|
str = str_replace(str, "å", rep); |
108 |
|
|
109 |
|
rep.at(0) = 230; |
110 |
|
str = str_replace(str, "æ", rep); |
111 |
|
|
112 |
|
rep.at(0) = 248; |
113 |
|
str = str_replace(str, "ø", 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]; |