Skip to content

Commit ef4dcfc

Browse files
authored
fix trim space while value is not unsigned char (#14)
1 parent 070ed8a commit ef4dcfc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

stringutils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,15 @@ class stringUtils
161161

162162
// trim from start (in place)
163163
static inline std::string ltrim(std::string &s) {
164-
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) {
165-
return !std::isspace(ch);
164+
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
165+
return !std::isspace(ch); // see:https://en.cppreference.com/w/cpp/string/byte/isspace
166166
}));
167167
return s;
168168
}
169169

170170
// trim from end (in place)
171171
static inline std::string rtrim(std::string &s) {
172-
s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) {
172+
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
173173
return !std::isspace(ch);
174174
}).base(), s.end());
175175
return s;

0 commit comments

Comments
 (0)