diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-04-14 16:20:36 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-04-14 16:20:36 +0000 |
commit | 470dd687adeb6bdff0c889588a2e31266fbaa575 (patch) | |
tree | 5a75f6099f58bb94f3442b956c23a5cef751b5fb /protocols/FacebookRM | |
parent | c687fa074736e24ad00d4fe6e4b7e8883f51c533 (diff) |
Facebook: better trim() fix
git-svn-id: http://svn.miranda-ng.org/main/trunk@8975 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r-- | protocols/FacebookRM/src/utils.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/protocols/FacebookRM/src/utils.cpp b/protocols/FacebookRM/src/utils.cpp index ce46bdbfe6..23f4ff4417 100644 --- a/protocols/FacebookRM/src/utils.cpp +++ b/protocols/FacebookRM/src/utils.cpp @@ -334,14 +334,11 @@ std::string utils::text::slashu_to_utf8(std::string data) std::string utils::text::trim(std::string data, bool rtrim)
{
- if (data.empty())
- return "";
-
- std::string spaces = " \t\r\n"; // TODO: include "nbsp"?
+ std::string spaces = " \t\r\n";
std::string::size_type begin = rtrim ? 0 : data.find_first_not_of(spaces);
- std::string::size_type end = data.find_last_not_of(spaces) + 1;
+ std::string::size_type end = data.find_last_not_of(spaces);
- return (begin != std::string::npos && end != std::string::npos) ? data.substr(begin, end - begin) : "";
+ return (end != std::string::npos) ? data.substr(begin, end + 1 - begin) : "";
}
void utils::text::explode(std::string str, std::string separator, std::vector<std::string>* results)
|