mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-26 10:31:34 +08:00
Use target.capacity() even with std::string
This commit is contained in:
parent
484bf07379
commit
5d6af189f1
@ -462,12 +462,8 @@ SPDLOG_INLINE void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SPDLOG_USE_STD_FORMAT
|
|
||||||
int result_size = 0;
|
|
||||||
#else
|
|
||||||
int result_size = static_cast<int>(target.capacity());
|
int result_size = static_cast<int>(target.capacity());
|
||||||
if ((wstr_size + 1) * 2 > result_size)
|
if ((wstr_size + 1) * 2 > result_size)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
result_size = ::WideCharToMultiByte(CP_UTF8, 0, wstr.data(), wstr_size, NULL, 0, NULL, NULL);
|
result_size = ::WideCharToMultiByte(CP_UTF8, 0, wstr.data(), wstr_size, NULL, 0, NULL, NULL);
|
||||||
}
|
}
|
||||||
@ -501,12 +497,8 @@ SPDLOG_INLINE void utf8_to_wstrbuf(string_view_t str, wmemory_buf_t &target)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SPDLOG_USE_STD_FORMAT
|
|
||||||
int result_size = 0;
|
|
||||||
#else
|
|
||||||
int result_size = static_cast<int>(target.capacity());
|
int result_size = static_cast<int>(target.capacity());
|
||||||
if (str_size + 1 > result_size)
|
if (str_size + 1 > result_size)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
result_size = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str.data(), str_size, NULL, 0);
|
result_size = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str.data(), str_size, NULL, 0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user