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

Diff of /smsdaemon/Util.cpp

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

revision 151 by torben, Mon Dec 8 10:42:04 2008 UTC revision 186 by torben, Mon Dec 15 09:27:56 2008 UTC
# Line 13  Line 13 
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    
# Line 146  namespace Util Line 146  namespace Util
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;
# Line 168  namespace Util Line 180  namespace Util
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          }          }
# Line 223  namespace Util Line 237  namespace Util
237                  string rep;                  string rep;
238                  rep.append(1,197);                  rep.append(1,197);
239                  str = str_replace(str, "&#197;", rep);                  str = str_replace(str, "&#197;", rep);
240                    str = str_replace(str, "&Aring;", rep);
241    
242                  rep.at(0) = 198;                  rep.at(0) = 198;
243                  str = str_replace(str, "&#198;", rep);                  str = str_replace(str, "&#198;", rep);
244                    str = str_replace(str, "&AElig;", rep);
245    
246                  rep.at(0) = 216;                  rep.at(0) = 216;
247                  str = str_replace(str, "&#216;", rep);                  str = str_replace(str, "&#216;", rep);
248                    str = str_replace(str, "&Oslash;", rep);
249    
250    
251                  rep.at(0) = 229;                  rep.at(0) = 229;
252                  str = str_replace(str, "&#229;", rep);                  str = str_replace(str, "&#229;", rep);
253                    str = str_replace(str, "&aring;", rep);
254    
255                  rep.at(0) = 230;                  rep.at(0) = 230;
256                  str = str_replace(str, "&#230;", rep);                  str = str_replace(str, "&#230;", rep);
257                    str = str_replace(str, "&aelig;", rep);
258    
259                  rep.at(0) = 248;                  rep.at(0) = 248;
260                  str = str_replace(str, "&#248;", rep);                  str = str_replace(str, "&#248;", rep);
261                    str = str_replace(str, "&oslash;", rep);
262    
263                  return str;                  return str;
264          }          }

Legend:
Removed from v.151  
changed lines
  Added in v.186

  ViewVC Help
Powered by ViewVC 1.1.20