diff options
-rw-r--r-- | tools.cpp | 13 | ||||
-rw-r--r-- | tools.h | 1 |
2 files changed, 14 insertions, 0 deletions
@@ -108,4 +108,17 @@ string StringEscapeAndBreak( string const& input ) return StringReplace( plainBuilder.str(), "\n", "<br/>" ); } +string StringTrim(string const& str) +{ + string res = str; + string::size_type pos = res.find_last_not_of(' '); + if(pos != string::npos) { + res.erase(pos + 1); + pos = res.find_first_not_of(' '); + if(pos != string::npos) res.erase(0, pos); + } + else res.erase(res.begin(), res.end()); + return res; +} + } // namespace vdrlive @@ -29,6 +29,7 @@ std::string StringRepeat(int times, const std::string& input); std::string StringWordTruncate(const std::string& input, size_t maxLen, bool& truncated); std::string StringEscapeAndBreak( std::string const& input ); std::string StringFormatBreak(std::string const& input); +std::string StringTrim(const std::string& str); struct bad_lexical_cast: std::runtime_error { |