19 out.
assign(stringView.size(), L
'\0');
20 std::use_facet<std::ctype<wchar_t>>(locale).widen(
22 stringView.data() + stringView.size(),
38 inline wstring_view
to_wstring(wstring_view stringView,
const std::locale& locale)
47 out.
assign(stringView.size(),
'\0');
48 std::use_facet<std::ctype<wchar_t>>(locale)
49 .narrow(stringView.data(), stringView.data() + stringView.size(),
'?', out.data());
64 inline cstring_view
to_cstring(cstring_view stringView,
const std::locale& locale)
69 inline void to_string(
string& out, cstring_view stringView,
const std::locale& locale)
73 #elif defined(QX_CONF_USE_WCHAR)
78 inline string to_string(cstring_view stringView,
const std::locale& locale)
82 #elif defined(QX_CONF_USE_WCHAR)
87 inline void to_string(
string& out, wstring_view stringView,
const std::locale& locale)
91 #elif defined(QX_CONF_USE_WCHAR)
96 inline string to_string(wstring_view stringView,
const std::locale& locale)
100 #elif defined(QX_CONF_USE_WCHAR)
109 #if QX_CONF_USE_WCHAR
113 const int nLength = MultiByteToWideChar(CP_UTF8, 0, pszUtf8.data(),
static_cast<int>(pszUtf8.size()),
nullptr, 0);
114 out.
assign(nLength, L
'\n');
115 MultiByteToWideChar(CP_UTF8, 0, pszUtf8.data(),
static_cast<int>(pszUtf8.size()), out.data(), nLength);
119 QX_PUSH_SUPPRESS_ALL_WARNINGS();
120 std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
121 out = converter.from_bytes(pszUtf8.data(), pszUtf8.data() + pszUtf8.size());
122 QX_POP_SUPPRESS_WARNINGS();
138 template<
class char_t,
size_t N>
139 constexpr std::array<char_t, N> to_char_array(std::span<const char, N> svChar)
141 std::array<char_t, N> result;
142 for (
size_t i = 0; i < N; ++i)
143 result[i] = svChar[i];
147 template<
class char_t,
string_literal array>
150 static constexpr
auto char_array =
151 to_char_array<char_t>(std::span<
const char, array.size()>(array.data(), array.data() + array.size()));
156 template<
class char_t,
string_literal array>
#define QX_SET_FILE_CATEGORY(_category)
Set the file category You can access this value via QX_GET_FILE_CATEGORY() This category will not be ...
void assign(size_type nSymbols, value_type chSymbol) noexcept
Assign by filling.
constexpr basic_string_view< char_t > convert_string_literal()
Convert a constexpr string literal to the wider or equal char type string view.
void to_wstring(wstring &out, cstring_view stringView, const std::locale &locale=std::locale())
convert cstring to wstring
void to_string(string &out, cstring_view stringView, const std::locale &locale=std::locale())
Convert a char string to common string type.
void utf8_to_string(string &out, cstring_view pszUtf8)
Convert const char* representing UTF8 to wstring.
void to_cstring(cstring &out, wstring_view stringView, const std::locale &locale=std::locale())
Convert wstring to cstring.