Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Commit

Permalink
In Cpp/Cx, empty Platform::String^ is null. Who knew?
Browse files Browse the repository at this point in the history
  • Loading branch information
Don Goodman-Wilson committed Dec 22, 2016
1 parent 0c9222a commit 2f2be44
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions support-lib/cx/Marshal.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,14 @@ namespace djinni {
using Boxed = String;

static CppType toCpp(CxType string) {
assert(string);
std::wstring wstring{ string->Data() };
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter;
return converter.to_bytes(wstring);
//Empty strings are null.
if(string)
{
std::wstring wstring{ string->Data() };
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter;
return converter.to_bytes(wstring);
}
return {""};
}

static CxType fromCpp(const CppType& string) {
Expand Down

0 comments on commit 2f2be44

Please sign in to comment.