42 |
return str; |
return str; |
43 |
} |
} |
44 |
|
|
45 |
|
std::string str_replace_char(std::string str, char search, char replace) |
46 |
|
{ |
47 |
|
unsigned int pos = 0; |
48 |
|
|
49 |
|
while ( (pos = str.find(search,pos)) != string::npos) |
50 |
|
{ |
51 |
|
str.replace(pos, 1, 1, replace); |
52 |
|
} |
53 |
|
return str; |
54 |
|
} |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
string str_trim(string str) |
string str_trim(string str) |
126 |
return str; |
return str; |
127 |
} |
} |
128 |
|
|
129 |
|
|
130 |
|
string str_gsm2latin1(string str) |
131 |
|
{ |
132 |
|
str = str_replace_char(str, 0x1c, 198); //AE |
133 |
|
str = str_replace_char(str, 0x0b, 216); //OE |
134 |
|
str = str_replace_char(str, 0x0e, 197); //AA |
135 |
|
|
136 |
|
str = str_replace_char(str, 0x1d, 230); //ae |
137 |
|
str = str_replace_char(str, 0x0c, 248); //oe |
138 |
|
str = str_replace_char(str, 0x0f, 229); //aa |
139 |
|
return str; |
140 |
|
} |
141 |
|
|
142 |
string readUrl(string url, string tempfile) |
string readUrl(string url, string tempfile) |
143 |
{ |
{ |
144 |
char buf[128000]; |
char buf[128000]; |
165 |
return document; |
return document; |
166 |
} |
} |
167 |
|
|
168 |
string convertToUnicode(string _input) |
|
169 |
|
|
170 |
|
string iconv_wrapper(string _input, string to_format, string from_format) |
171 |
{ |
{ |
172 |
char* input,*output,*input_ptr, *output_ptr; |
char* input,*output,*input_ptr, *output_ptr; |
173 |
input = input_ptr = (char*) malloc(_input.size()+1); |
input = input_ptr = (char*) malloc(_input.size()+1); |
179 |
|
|
180 |
unsigned int realinsize,insize,outsize,realsize; |
unsigned int realinsize,insize,outsize,realsize; |
181 |
|
|
182 |
iconv_t icv = iconv_open("UTF8", "ISO8859-1"); |
iconv_t icv = iconv_open(to_format.c_str(), from_format.c_str()); |
183 |
if (icv == (iconv_t)-1) |
if (icv == (iconv_t)-1) |
184 |
{ |
{ |
185 |
perror(0); |
perror(0); |
215 |
return returnstr; |
return returnstr; |
216 |
} |
} |
217 |
|
|
218 |
|
std::string convertToUnicode(std::string str) |
219 |
|
{ |
220 |
|
return iconv_wrapper(str, "UTF-8", "ISO8859-1"); |
221 |
|
} |
222 |
|
|
223 |
|
std::string convertFromUnicode(std::string str) |
224 |
|
{ |
225 |
|
return iconv_wrapper(str, "ISO8859-1", "UTF-8"); |
226 |
|
} |
227 |
|
|
228 |
int uTimeDiff(const timeval& then, const timeval& now) |
int uTimeDiff(const timeval& then, const timeval& now) |
229 |
{ |
{ |
230 |
return ( (now.tv_sec - then.tv_sec)*1000000) + (now.tv_usec-then.tv_usec); |
return ( (now.tv_sec - then.tv_sec)*1000000) + (now.tv_usec-then.tv_usec); |