Add window support for Windows.
This commit is contained in:
parent
5d32592126
commit
c05b7b6315
27 changed files with 783 additions and 95 deletions
|
@ -2,6 +2,10 @@
|
|||
#include <locale>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Windows.h"
|
||||
#endif
|
||||
|
||||
bool StringUtils::IsAlphaNumeric(char c)
|
||||
{
|
||||
std::locale loc;
|
||||
|
@ -21,3 +25,23 @@ std::string StringUtils::ToLower(const std::string& s)
|
|||
[](unsigned char c){ return std::tolower(c); });
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string StringUtils::convert(const std::wstring& input)
|
||||
{
|
||||
if (input.empty())
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
const auto size = ::WideCharToMultiByte(CP_UTF8, 0, &input[0],
|
||||
(int)input.size(), nullptr, 0, nullptr, nullptr);
|
||||
|
||||
std::string result(size, 0);
|
||||
::WideCharToMultiByte(CP_UTF8, 0, &input[0], (int)input.size(),
|
||||
&result[0], size, nullptr, nullptr);
|
||||
return result;
|
||||
#else
|
||||
throw std::logic_error("Not implemented");
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue