mirror of https://github.com/PCSX2/pcsx2.git
common: pull our string functions into common
This commit is contained in:
parent
be952e40ba
commit
e313eadcd2
|
@ -19,6 +19,7 @@
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "RedtapeWindows.h"
|
#include "RedtapeWindows.h"
|
||||||
|
@ -206,6 +207,35 @@ namespace StringUtil
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string toLower(const std::string_view& input)
|
||||||
|
{
|
||||||
|
std::string newStr;
|
||||||
|
std::transform(input.begin(), input.end(), std::back_inserter(newStr),
|
||||||
|
[](unsigned char c) { return std::tolower(c); });
|
||||||
|
return newStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool compareNoCase(const std::string_view& str1, const std::string_view& str2)
|
||||||
|
{
|
||||||
|
if (str1.length() != str2.length())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Strncasecmp(str1.data(), str2.data(), str1.length()) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> splitOnNewLine(const std::string& str)
|
||||||
|
{
|
||||||
|
std::vector<std::string> lines;
|
||||||
|
std::istringstream stream(str);
|
||||||
|
std::string line;
|
||||||
|
while (std::getline(stream, line))
|
||||||
|
{
|
||||||
|
lines.push_back(line);
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
std::wstring UTF8StringToWideString(const std::string_view& str)
|
std::wstring UTF8StringToWideString(const std::string_view& str)
|
||||||
|
|
|
@ -184,6 +184,10 @@ namespace StringUtil
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string toLower(const std::string_view& str);
|
||||||
|
bool compareNoCase(const std::string_view& str1, const std::string_view& str2);
|
||||||
|
std::vector<std::string> splitOnNewLine(const std::string& str);
|
||||||
|
|
||||||
/// Converts a wxString to a UTF-8 std::string.
|
/// Converts a wxString to a UTF-8 std::string.
|
||||||
static std::string wxStringToUTF8String(const wxString& str)
|
static std::string wxStringToUTF8String(const wxString& str)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue