MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / utf8ToSystem

Function utf8ToSystem

source/MRMesh/MRStringConvert.cpp:70–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70std::string utf8ToSystem( const std::string & utf8 )
71{
72#ifdef _WIN32
73 auto utf16 = utf8ToWide( utf8.c_str() );
74 auto rsize = WideCharToMultiByte( CP_ACP, 0, utf16.data(), ( int )utf16.size(), NULL, 0, NULL, NULL );
75 std::string res( size_t ( rsize ), '\0' );
76 BOOL usedDefaultChar = FALSE;
77 rsize = WideCharToMultiByte( CP_ACP, 0, utf16.data(), (int)utf16.size(), res.data(), int( res.size() ), NULL, &usedDefaultChar );
78 if ( usedDefaultChar || rsize == 0 )
79 {
80 spdlog::error( GetLastError() );
81 return {};
82 }
83 res.resize( rsize );
84 return res;
85#else
86 return utf8;
87#endif
88}
89
90std::string utf8substr( const char * s, size_t pos, size_t count )
91{

Callers

nothing calls this directly

Calls 4

utf8ToWideFunction · 0.70
dataMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected