13 #pragma warning(disable : 4365 4987)
25template<
typename TCharacter>
46 const std::size_t
length = std::strlen(source);
47 const int neededSize = MultiByteToWideChar(CP_UTF8, 0, source,
static_cast<int>(
length),
nullptr, 0);
48 StringType result{
static_cast<std::size_t
>(neededSize), 0, memRes};
49 MultiByteToWideChar(CP_UTF8, 0, source,
static_cast<int>(
length), &result[0], neededSize);
52 const char* current = std::setlocale(LC_ALL,
nullptr);
53 std::setlocale(LC_ALL,
"en_US.utf8");
55 std::mbstate_t state{};
56 const std::size_t neededSize = std::mbsrtowcs(
nullptr, &source, 0, &state) + 1ul;
58 std::mbsrtowcs(&result[0], &source, result.size(), &state);
60 if (current !=
nullptr) {
61 std::setlocale(LC_ALL, current);
70#if defined(_WIN32) && defined(UNICODE)
MemoryResource is an abstract class that allows the implementation of polymorphic allocators.
Definition: MemoryResource.h:17
std::basic_string< T, std::char_traits< T >, Allocator > String
Definition: include/pma/TypeDefs.h:26
std::enable_if< std::is_floating_point< T >::value, T >::type length(const vec< L, T > &v)
Definition: Computations.h:46
Definition: Concepts.h:10
char NativeCharacter
Definition: NativeString.h:73
pma::String< NativeCharacter > NativeString
Definition: NativeString.h:76
char CharacterType
Definition: NativeString.h:30
static StringType from(const char *source, pma::MemoryResource *memRes)
Definition: NativeString.h:33
pma::String< CharacterType > StringType
Definition: NativeString.h:31
wchar_t CharacterType
Definition: NativeString.h:41
static StringType from(const char *source, pma::MemoryResource *memRes)
Definition: NativeString.h:44
pma::String< CharacterType > StringType
Definition: NativeString.h:42
Definition: NativeString.h:26