5 const auto BufferSize(
Core().FModuleManager.Call<CYB::Platform::Modules::Kernel32::MultiByteToWideChar>(CYB::Platform::Win32::UINT(CP_UTF8), CYB::Platform::Win32::DWORD(0), AUTF8.
CString(), -1,
nullptr, 0));
6 ALengthReference = BufferSize *
sizeof(wchar_t);
7 Assert::LessThan<unsigned long long>(ALengthReference,
static_cast<unsigned long long>(std::numeric_limits<int>::max()));
8 auto NewData(static_cast<wchar_t*>(
Context().FAllocator.FHeap.Alloc(static_cast<int>(ALengthReference))));
9 if (
CYB::Core().FModuleManager.Call<CYB::Platform::Modules::Kernel32::MultiByteToWideChar>(CYB::Platform::Win32::UINT(CP_UTF8), CYB::Platform::Win32::DWORD(0), AUTF8.
CString(), -1, NewData, BufferSize) == 0) {
13 return reinterpret_cast<char*
>(NewData);
16 const auto BufferSize(
CYB::Core().FModuleManager.Call<CYB::Platform::Modules::Kernel32::WideCharToMultiByte>(CYB::Platform::Win32::UINT(CP_UTF8), CYB::Platform::Win32::DWORD(0), AWString, -1,
nullptr, 0,
nullptr,
nullptr));
17 auto NewData(static_cast<char*>(
Context().FAllocator.FHeap.Alloc(BufferSize)));
18 if (NewData !=
nullptr &&
Core().FModuleManager.Call<CYB::Platform::Modules::Kernel32::WideCharToMultiByte>(CYB::Platform::Win32::UINT(CP_UTF8), CYB::Platform::Win32::DWORD(0), AWString, -1, NewData, BufferSize,
nullptr,
nullptr) == 0)
20 return UTF8(FromData(NewData));
28 Dynamic(SetupData(AUTF8, ALengthReference))
30 API::Assert::LessThan(ALengthReference, static_cast<unsigned long long>(std::numeric_limits<int>::max()));
31 FLength =
static_cast<int>(ALengthReference);
35 return reinterpret_cast<wchar_t*
>(FData);
38 return reinterpret_cast<const wchar_t*
>(FData);
A variable length UTF-8 string.
UTF16() noexcept=default
Empty string constructor.
API::Interop::Context & Context(void) noexcept
Get the API's Context.
Heap & FHeap
The Heap this allocator uses.
wchar_t * WideData(void) noexcept
Get the underlying wide char array.
UTF-16 String enabled only under windows.
Used for string of allocated variable length.
static void LessThan(const AType &ALHS, const AType &ARHS) noexcept
Less than assertion function. May not be evaluated.
A string could not be validated.
static UTF8 ToUTF8(const wchar_t *AWString)
Create a new UTF8 string given a wide char array.
virtual void Free(void *const APreviousAllocation) noexcept=0
Return memory to the heap. Data in allocated range will be lost.
Exceptions caused by external call failures or invalid external data. Only classifies ones that can p...
int FLength
Number of bytes before null terminator in FData.
Allocator & FAllocator
The Allocator.
const wchar_t * WString(void) const noexcept
Get the underlying const wide char array.
Precompiled header for inter-engine operations.
const char * CString(void) const noexcept
Get the contained const CString.
Engine::Core & Core(void) noexcept
Retrieve the Core singleton.
static char * SetupData(const UTF8 &AUTF8, unsigned long long &ALengthReference)
Construct a raw allocated UTF16 wide char array casted to a char array given a UTF8 string...