WebSocket_CPP_98/CC_SDK_VS/WebSocket/string_helper.cpp
2025-12-29 09:55:17 +08:00

22 lines
472 B
C++

#include "string_helper.h"
#include <algorithm>
#include <cctype>
std::string& strHelper::trim(std::string& str, const char thechar)
{
if (str.empty()) {
return str;
}
std::string::size_type pos = str.find_first_not_of(thechar);
if (pos != std::string::npos) {
str.erase(0, pos);
}
pos = str.find_last_of(thechar);
if (pos != std::string::npos) {
str.erase(str.find_last_not_of(thechar) + 1);
}
return str;
}