mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 05:21:25 +12:00
Gives ANSI path to curl CURLOPT_CAINFO
This commit is contained in:
parent
2aac46efcc
commit
cd4eed0704
5 changed files with 72 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
|||
#include "StrFmt.h"
|
||||
#include "StrFmt.h"
|
||||
#include "BEType.h"
|
||||
#include "StrUtil.h"
|
||||
#include "cfmt.h"
|
||||
|
@ -14,6 +14,47 @@
|
|||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
std::string wchar_to_utf8(wchar_t *src)
|
||||
{
|
||||
std::string utf8_string;
|
||||
auto tmp_size = WideCharToMultiByte(CP_UTF8, 0, src, -1, nullptr, 0, nullptr, nullptr);
|
||||
utf8_string.resize(tmp_size);
|
||||
WideCharToMultiByte(CP_UTF8, 0, src, -1, utf8_string.data(), tmp_size, nullptr, nullptr);
|
||||
return utf8_string;
|
||||
}
|
||||
|
||||
std::string wchar_path_to_ansi_path(const std::wstring& src)
|
||||
{
|
||||
std::wstring buf_short;
|
||||
std::string buf_final;
|
||||
|
||||
// Get the short path from the wide char path(short path should only contain ansi characters)
|
||||
auto tmp_size = GetShortPathNameW(src.data(), nullptr, 0);
|
||||
buf_short.resize(tmp_size);
|
||||
GetShortPathNameW(src.data(), buf_short.data(), tmp_size);
|
||||
|
||||
// Convert wide char to ansi
|
||||
tmp_size = WideCharToMultiByte(CP_ACP, 0, buf_short.data(), -1, nullptr, 0, nullptr, nullptr);
|
||||
buf_final.resize(tmp_size);
|
||||
WideCharToMultiByte(CP_ACP, 0, buf_short.data(), -1, buf_final.data(), tmp_size, nullptr, nullptr);
|
||||
|
||||
return buf_final;
|
||||
}
|
||||
|
||||
std::string utf8_path_to_ansi_path(const std::string& src)
|
||||
{
|
||||
std::wstring buf_wide;
|
||||
|
||||
// Converts the utf-8 path to wide char
|
||||
auto tmp_size = MultiByteToWideChar(CP_UTF8, 0, src.c_str(), -1, nullptr, 0);
|
||||
buf_wide.resize(tmp_size);
|
||||
MultiByteToWideChar(CP_UTF8, 0, src.c_str(), -1, buf_wide.data(), tmp_size);
|
||||
|
||||
return wchar_path_to_ansi_path(buf_wide);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <>
|
||||
void fmt_class_string<std::pair<const fmt_type_info*, u64>>::format(std::string& out, u64 arg)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue