mirror of https://github.com/PCSX2/pcsx2.git
Common/StringUtil: Add whitespace strip methods
This commit is contained in:
parent
1a598ccf0d
commit
92689a60ae
|
@ -236,6 +236,21 @@ namespace StringUtil
|
|||
return lines;
|
||||
}
|
||||
|
||||
std::string_view StripWhitespace(const std::string_view& str)
|
||||
{
|
||||
std::string_view::size_type start = 0;
|
||||
while (start < str.size() && std::isspace(str[start]))
|
||||
start++;
|
||||
if (start == str.size())
|
||||
return {};
|
||||
|
||||
std::string_view::size_type end = str.size() - 1;
|
||||
while (end > start && std::isspace(str[end]))
|
||||
end--;
|
||||
|
||||
return str.substr(start, end - start + 1);
|
||||
}
|
||||
|
||||
std::wstring UTF8StringToWideString(const std::string_view& str)
|
||||
{
|
||||
std::wstring ret;
|
||||
|
|
|
@ -153,6 +153,9 @@ namespace StringUtil
|
|||
return (str.length() >= suffix_length && str.compare(str.length() - suffix_length, suffix_length, suffix) == 0);
|
||||
}
|
||||
|
||||
/// Strip whitespace from the start/end of the string.
|
||||
std::string_view StripWhitespace(const std::string_view& str);
|
||||
|
||||
/// Strided memcpy/memcmp.
|
||||
static inline void StrideMemCpy(void* dst, std::size_t dst_stride, const void* src, std::size_t src_stride,
|
||||
std::size_t copy_size, std::size_t count)
|
||||
|
|
Loading…
Reference in New Issue