mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-14 06:48:39 -04:00
Add sys_string_to_string() conversion function
This commit is contained in:
parent
4686baca2d
commit
cfa54bc81a
@ -25,6 +25,8 @@
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
#include "dwarfs/types.h"
|
||||
|
||||
namespace dwarfs {
|
||||
|
||||
std::string time_with_unit(double sec);
|
||||
@ -40,4 +42,6 @@ inline std::string u8string_to_string(std::u8string const& in) {
|
||||
return std::string(reinterpret_cast<char const*>(in.data()), in.size());
|
||||
}
|
||||
|
||||
std::string sys_string_to_string(sys_string const& in);
|
||||
|
||||
} // namespace dwarfs
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include <array>
|
||||
#include <charconv>
|
||||
#include <climits>
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
@ -118,4 +120,13 @@ std::chrono::milliseconds parse_time_with_unit(std::string const& str) {
|
||||
DWARFS_THROW(runtime_error, "unsupported time suffix");
|
||||
}
|
||||
|
||||
std::string sys_string_to_string(sys_string const& in) {
|
||||
#ifdef _WIN32
|
||||
static std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter;
|
||||
return converter.to_bytes(in);
|
||||
#else
|
||||
return in;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace dwarfs
|
||||
|
Loading…
x
Reference in New Issue
Block a user