Commit 935f066a authored by bastien penavayre's avatar bastien penavayre Committed by Hugo Beauzée-Luyssen

Fix bug with converting native strings to Platform::String

- ToPlatformString will never call ref new Platform::String(NULL), but ref new Platform::String("") instead
Signed-off-by: default avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent be3370be
......@@ -35,6 +35,8 @@ char *FromPlatformString(Platform::String^ str)
Platform::String^
ToPlatformString(const char *str) {
if (str == NULL)
return ref new Platform::String();
size_t len = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
if (len == 0)
return nullptr;
......@@ -46,5 +48,5 @@ ToPlatformString(const char *str) {
Platform::String^
ToPlatformString(const std::string& str)
{
return ToPlatformString(str.c_str());
return ToPlatformString(str.c_str() == NULL ? "" : str.c_str());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment