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

Function systemToUtf8

source/MRMesh/MRStringConvert.cpp:49–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47#endif
48
49std::string systemToUtf8( const std::string & msg )
50{
51#ifdef _WIN32
52 if ( msg.empty() )
53 return msg;
54 auto rsize = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, msg.data(), int( msg.size() ), nullptr, 0 );
55 std::wstring wmsg;
56 wmsg.resize( size_t( rsize ) );
57 rsize = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, msg.data(), int( msg.size() ), wmsg.data(), int( wmsg.size() ) );
58 if ( rsize == 0 )
59 {
60 spdlog::error( GetLastError() );
61 return {};
62 }
63 wmsg.resize( rsize );
64 return Utf16ToUtf8( wmsg );
65#else
66 return msg;
67#endif
68}
69
70std::string utf8ToSystem( const std::string & utf8 )
71{

Callers 8

loadPresetMethod · 0.85
savePresetMethod · 0.85
update_Method · 0.85
saveObjectToFileFunction · 0.85
UniqueTemporaryFolderMethod · 0.85
getUserConfigDirFunction · 0.85
exportNesting3mfFunction · 0.85

Calls 5

Utf16ToUtf8Function · 0.85
emptyMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected