Update string_format.cpp (#1184)

This commit is contained in:
Kyle Reed 2023-06-23 15:08:11 -07:00 committed by GitHub
parent 0dea488e98
commit 6b0f90c321
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -286,7 +286,7 @@ static const char* whitespace_str = " \t\r\n";
std::string trim(std::string_view str) {
auto first = str.find_first_not_of(whitespace_str);
auto last = str.find_last_not_of(whitespace_str);
return std::string{str.substr(first, last - first)};
return std::string{str.substr(first, last - first + 1)};
}
std::string trimr(std::string_view str) {
@ -296,4 +296,4 @@ std::string trimr(std::string_view str) {
std::string truncate(std::string_view str, size_t length) {
return std::string{str.length() <= length ? str : str.substr(0, length)};
}
}