NativeString.h pma/TypeDefs.h clocale cstddef cstring cwchar FileStreamImpl.cpp FileStreamImpl.h trio::StringConverter< char > trio::StringConverter< wchar_t > trio //CopyrightEpicGames,Inc.AllRightsReserved. #pragmaonce #ifdef_WIN32 #include"trio/utils/PlatformWindows.h" #endif #include<pma/TypeDefs.h> #ifdef_MSC_VER #pragmawarning(push) #pragmawarning(disable:43654987) #endif #include<clocale> #include<cstddef> #include<cstring> #include<cwchar> #ifdef_MSC_VER #pragmawarning(pop) #endif namespacetrio{ template<typenameTCharacter> structStringConverter; template<> structStringConverter<char>{ usingCharacterType=char; usingStringType=pma::String<CharacterType>; staticStringTypefrom(constchar*source,pma::MemoryResource*memRes){ returnStringType{source,memRes}; } }; template<> structStringConverter<wchar_t>{ usingCharacterType=wchar_t; usingStringType=pma::String<CharacterType>; staticStringTypefrom(constchar*source,pma::MemoryResource*memRes){ #ifdef_WIN32 conststd::size_tlength=std::strlen(source); constintneededSize=MultiByteToWideChar(CP_UTF8,0,source,static_cast<int>(length),nullptr,0); StringTyperesult{static_cast<std::size_t>(neededSize),0,memRes}; MultiByteToWideChar(CP_UTF8,0,source,static_cast<int>(length),&result[0],neededSize); returnresult; #else constchar*current=std::setlocale(LC_ALL,nullptr); std::setlocale(LC_ALL,"en_US.utf8");//AnyUTF-8localewillwork std::mbstate_tstate{}; conststd::size_tneededSize=std::mbsrtowcs(nullptr,&source,0,&state)+1ul; StringTyperesult{neededSize,0,memRes}; std::mbsrtowcs(&result[0],&source,result.size(),&state); if(current!=nullptr){ std::setlocale(LC_ALL,current); } returnresult; #endif } }; #ifdefined(_WIN32)&&defined(UNICODE) usingNativeCharacter=wchar_t; #else usingNativeCharacter=char; #endif usingNativeString=pma::String<NativeCharacter>; usingNativeStringConverter=StringConverter<NativeCharacter>; }//namespacetrio