13 |
#include <stdlib.h> |
#include <stdlib.h> |
14 |
|
|
15 |
#include <cstring> |
#include <cstring> |
16 |
#include "util.h" |
#include "Util.h" |
17 |
|
|
18 |
using namespace std; |
using namespace std; |
19 |
|
|
146 |
return str; |
return str; |
147 |
} |
} |
148 |
|
|
149 |
|
|
150 |
|
vector<string> str_split(string input) |
151 |
|
{ |
152 |
|
string buf; |
153 |
|
stringstream ss(input); |
154 |
|
vector<string> tokens; |
155 |
|
while (ss >> buf) |
156 |
|
tokens.push_back(buf); |
157 |
|
return tokens; |
158 |
|
} |
159 |
|
|
160 |
|
|
161 |
vector<string> str_split(string input, string delimiter) |
vector<string> str_split(string input, string delimiter) |
162 |
{ |
{ |
163 |
vector<string> retval; |
vector<string> retval; |
180 |
return retval; |
return retval; |
181 |
} |
} |
182 |
|
|
183 |
char my_toupper(char ch) |
char danish_map[3][2] = { {198,230}, {216,248}, {197,229} }; // aelig, oslash, aring |
184 |
|
|
185 |
|
unsigned char my_toupper(unsigned char ch) |
186 |
{ |
{ |
187 |
if (ch == 'æ') |
if (ch == 230) |
188 |
return 'Æ'; |
return 198; |
189 |
if (ch == 'ø') |
if (ch == 248) |
190 |
return 'Ø'; |
return 216; |
191 |
if (ch == 'å') |
if (ch == 229) |
192 |
return 'Å'; |
return 197; |
193 |
|
|
194 |
return ::toupper(ch); |
return ::toupper(ch); |
195 |
} |
} |
196 |
|
|
197 |
char my_tolower(char ch) |
unsigned char my_tolower(unsigned char ch) |
198 |
{ |
{ |
199 |
if (ch == 'Æ') |
if (ch == 198) |
200 |
return 'æ'; |
return 230; |
201 |
if (ch == 'Ø') |
if (ch == 216) |
202 |
return 'ø'; |
return 248; |
203 |
if (ch == 'Å') |
if (ch == 197) |
204 |
return 'å'; |
return 229; |
205 |
|
|
206 |
return ::tolower(ch); |
return ::tolower(ch); |
207 |
} |
} |
417 |
ifstream in(filename.c_str()); |
ifstream in(filename.c_str()); |
418 |
if (in) |
if (in) |
419 |
{ |
{ |
420 |
char buffer[2048]; |
char buffer[4096]; |
421 |
in.read(buffer, 2047); |
in.read(buffer, 4095); |
422 |
buffer[ in.gcount() ] = 0; |
buffer[ in.gcount() ] = 0; |
423 |
str = string(buffer); |
str = string(buffer); |
424 |
in.close(); |
in.close(); |
425 |
} |
} |
426 |
else |
else |
427 |
{ |
{ |
428 |
string message = "Could no open "; |
string message = "Could not open "; |
429 |
message += filename; |
message += filename; |
430 |
throw std::runtime_error(message); |
throw std::runtime_error(message); |
431 |
} |
} |