MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / convert

Method convert

extlibs/fmt/src/os.cc:83–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83int internal::utf16_to_utf8::convert(wstring_view s) {
84 if (s.size() > INT_MAX) return ERROR_INVALID_PARAMETER;
85 int s_size = static_cast<int>(s.size());
86 if (s_size == 0) {
87 // WideCharToMultiByte does not support zero length, handle separately.
88 buffer_.resize(1);
89 buffer_[0] = 0;
90 return 0;
91 }
92
93 int length = WideCharToMultiByte(CP_UTF8, 0, s.data(), s_size, nullptr, 0,
94 nullptr, nullptr);
95 if (length == 0) return GetLastError();
96 buffer_.resize(length + 1);
97 length = WideCharToMultiByte(CP_UTF8, 0, s.data(), s_size, &buffer_[0],
98 length, nullptr, nullptr);
99 if (length == 0) return GetLastError();
100 buffer_[length] = 0;
101 return 0;
102}
103
104void windows_error::init(int err_code, string_view format_str,
105 format_args args) {

Callers 1

os.ccFile · 0.45

Calls 3

resizeMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected