1#ifndef _LOGIT_ENCODING_UTILS_HPP_INCLUDED
2#define _LOGIT_ENCODING_UTILS_HPP_INCLUDED
15 std::string utf8_to_ansi(
const std::string& utf8) {
16 int n_len = MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), -1, NULL, 0);
17 if (n_len == 0)
return {};
19 std::wstring wide_string(n_len + 1, L
'\0');
20 MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), -1, &wide_string[0], n_len);
22 n_len = WideCharToMultiByte(CP_ACP, 0, wide_string.c_str(), -1, NULL, 0, NULL, NULL);
23 if (n_len == 0)
return {};
25 std::string ansi_string(n_len - 1,
'\0');
26 WideCharToMultiByte(CP_ACP, 0, wide_string.c_str(), -1, &ansi_string[0], n_len, NULL, NULL);
The primary namespace for the LogIt++ library.