mirror of
https://github.com/vimpunk/mio.git
synced 2025-12-06 08:46:51 +08:00
Merge pull request #88 from pps83/master-fix-linker-s_2_ws
Avoid multiply defined `s_2_ws` linker error
This commit is contained in:
commit
8b6b7d878c
@ -52,14 +52,17 @@ inline DWORD int64_low(int64_t n) noexcept
|
||||
return n & 0xffffffff;
|
||||
}
|
||||
|
||||
std::wstring s_2_ws(const std::string& s)
|
||||
inline std::wstring s_2_ws(const std::string& s)
|
||||
{
|
||||
if (s.empty())
|
||||
return{};
|
||||
const auto s_length = static_cast<int>(s.length());
|
||||
auto buf = std::vector<wchar_t>(s_length);
|
||||
const auto wide_char_count = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), s_length, buf.data(), s_length);
|
||||
return std::wstring(buf.data(), wide_char_count);
|
||||
std::wstring ret;
|
||||
if (!s.empty())
|
||||
{
|
||||
ret.resize(s.size());
|
||||
int wide_char_count = MultiByteToWideChar(CP_UTF8, 0, s.c_str(),
|
||||
static_cast<int>(s.size()), &ret[0], static_cast<int>(s.size()));
|
||||
ret.resize(wide_char_count);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<
|
||||
|
||||
@ -794,14 +794,17 @@ inline DWORD int64_low(int64_t n) noexcept
|
||||
return n & 0xffffffff;
|
||||
}
|
||||
|
||||
std::wstring s_2_ws(const std::string& s)
|
||||
inline std::wstring s_2_ws(const std::string& s)
|
||||
{
|
||||
if (s.empty())
|
||||
return{};
|
||||
const auto s_length = static_cast<int>(s.length());
|
||||
auto buf = std::vector<wchar_t>(s_length);
|
||||
const auto wide_char_count = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), s_length, buf.data(), s_length);
|
||||
return std::wstring(buf.data(), wide_char_count);
|
||||
std::wstring ret;
|
||||
if (!s.empty())
|
||||
{
|
||||
ret.resize(s.size());
|
||||
int wide_char_count = MultiByteToWideChar(CP_UTF8, 0, s.c_str(),
|
||||
static_cast<int>(s.size()), &ret[0], static_cast<int>(s.size()));
|
||||
ret.resize(wide_char_count);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user