52 const std::string::size_type endpos = str.find_last_not_of(
" \t\n\r");
53 if (std::string::npos != endpos) {
54 const int startpos = (int)str.find_first_not_of(
" \t\n\r");
55 return str.substr(startpos, endpos - startpos + 1);
63 for (
int i = 0; i < (int)str.length(); i++) {
64 if (str[i] >=
'A' && str[i] <=
'Z') {
65 str[i] = str[i] +
'a' -
'A';
76 for (
int i = 0; i < (int)str.length(); i++) {
77 const unsigned char c = str[i];
81 result += (char)(0xc2 + (c > 0xbf));
82 result += (char)((c & 0x3f) + 0x80);
91 str =
replace(str,
"\xE4",
"ae");
92 str =
replace(str,
"\xC4",
"Ae");
93 str =
replace(str,
"\xF6",
"oe");
94 str =
replace(str,
"\xD6",
"Oe");
95 str =
replace(str,
"\xFC",
"ue");
96 str =
replace(str,
"\xDC",
"Ue");
97 str =
replace(str,
"\xDF",
"ss");
98 str =
replace(str,
"\xC9",
"E");
99 str =
replace(str,
"\xE9",
"e");
100 str =
replace(str,
"\xC8",
"E");
101 str =
replace(str,
"\xE8",
"e");
110 const std::string what_tmp(what);
111 const std::string by_tmp(by);
112 std::string::size_type idx = str.find(what);
113 const int what_len = (int)what_tmp.length();
115 const int by_len = (int)by_tmp.length();
116 while (idx != std::string::npos) {
117 str = str.replace(idx, what_len, by);
118 idx = str.find(what, idx + by_len);
127 std::ostringstream oss;
133 sprintf(buffer,
"%02i:", (time / 3600));
136 sprintf(buffer,
"%02i:", (time / 60));
139 sprintf(buffer,
"%02i", time);
147 return str.compare(0, prefix.length(), prefix) == 0;
153 if (str.length() >= suffix.length()) {
154 return str.compare(str.length() - suffix.length(), suffix.length(), suffix) == 0;
163 std::string result =
replace(orig,
"&",
"&");
164 result =
replace(result,
">",
">");
165 result =
replace(result,
"<",
"<");
166 result =
replace(result,
"\"",
""");
167 if (maskDoubleHyphen) {
168 result =
replace(result,
"--",
"--");
170 for (
char invalid =
'\1'; invalid <
' '; invalid++) {
171 result =
replace(result, std::string(1, invalid).c_str(),
"");
173 return replace(result,
"'",
"'");
179 std::ostringstream out;
181 for (
int i = 0; i < (int)toEncode.length(); ++i) {
182 const char t = toEncode.at(i);
184 if ((encodeWhich !=
"" && encodeWhich.find(t) == std::string::npos) ||
185 (encodeWhich ==
"" &&
186 ((t >= 45 && t <= 57) ||
187 (t >= 65 && t <= 90) ||
189 (t >= 97 && t <= 122) ||
192 out << toEncode.at(i);
203 std::ostringstream out;
205 for (
int i = 0; i < (int)toDecode.length(); ++i) {
206 if (toDecode.at(i) ==
'%') {
207 std::string str(toDecode.substr(i + 1, 2));
211 out << toDecode.at(i);
224 s <<
"%" << std::setw(2) << std::setfill(
'0') << std::hex << i;
234 std::istringstream in(str);
239 throw std::runtime_error(
"stream decode failure");
243 return static_cast<unsigned char>(c);
static unsigned char hexToChar(const std::string &str)
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
static std::string toTimeString(int time)
Builds a time string (hh:mm:ss) from the given seconds.
static std::string latin1_to_utf8(std::string str)
Transfers from Latin 1 (ISO-8859-1) to UTF-8.
static std::string urlEncode(const std::string &url, const std::string encodeWhich="")
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
static std::string convertUmlaute(std::string str)
Converts german "Umlaute" to their latin-version.
static std::string emptyString
An empty string.
static std::string replace(std::string str, const char *what, const char *by)
static std::string to_lower_case(std::string str)
Transfers the content to lower case.
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.
static std::string urlDecode(const std::string &encoded)
static std::string charToHex(unsigned char c)