From 56cd831ec82250b00455e19c6321b8c6109a107b Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Thu, 26 Feb 2026 00:09:43 -0600 Subject: [PATCH] Fix str::trim to handle all whitespace characters Use std::isspace() instead of comparing only to space character. Now handles tabs, newlines, carriage returns, etc. --- src/str.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/str.cpp b/src/str.cpp index 88ec0415..f823bad8 100644 --- a/src/str.cpp +++ b/src/str.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -304,9 +305,9 @@ str::trim(const std::string &str_) rv = str_; - while(!rv.empty() && (rv[0] == ' ')) + while(!rv.empty() && std::isspace(static_cast(rv[0]))) rv.erase(0); - while(!rv.empty() && (rv[rv.size()-1] == ' ')) + while(!rv.empty() && std::isspace(static_cast(rv[rv.size()-1]))) rv.erase(rv.size()-1); return rv;