Files
FEX-Emu--FEX/Source/Common/StringUtil.cpp
T
Ryan Houdek 47369d058e Utils/StringUtil: Fixes ltrim and adds a unittest
ltrim had the issue that it would always consume the left-most character
even if it wasn't whitespace. So `FEXLoader` would turn in to
`EXLoader`, even without any whitespace in the string.

Adds a test to ensure this doesn't occur again.
2024-11-26 12:57:48 -08:00

17 lines
449 B
C++

// SPDX-License-Identifier: MIT
#include "Common/StringUtil.h"
namespace FEX::StringUtil {
void ltrim(fextl::string& s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) { return !std::isspace(ch); }));
}
void rtrim(fextl::string& s) {
s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { return !std::isspace(ch); }).base(), s.end());
}
void trim(fextl::string& s) {
ltrim(s);
rtrim(s);
}
} // namespace FEX::StringUtil