From b939c8baf5fe33ef9eced1c3de7acb64b8c7e7b5 Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Mon, 2 Oct 2017 17:11:05 -0700 Subject: Adding inheritance test --- matlab/src/IceMatlab/Util.cpp | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'matlab/src') diff --git a/matlab/src/IceMatlab/Util.cpp b/matlab/src/IceMatlab/Util.cpp index 854f8594acb..6259061d7e7 100644 --- a/matlab/src/IceMatlab/Util.cpp +++ b/matlab/src/IceMatlab/Util.cpp @@ -58,27 +58,34 @@ getMajorMinor(mxArray* p, Ice::Byte& major, Ice::Byte& minor) mxArray* IceMatlab::createStringFromUTF8(const string& s) { + if(s.empty()) + { + return mxCreateString(""); + } + else + { #ifdef _MSC_VER - // - // Workaround for Visual Studio bug that causes a link error when using char16_t. - // - wstring utf16 = wstring_convert, wchar_t>{}.from_bytes(s.data()); + // + // Workaround for Visual Studio bug that causes a link error when using char16_t. + // + wstring utf16 = wstring_convert, wchar_t>{}.from_bytes(s.data()); #else - u16string utf16 = wstring_convert, char16_t>{}.from_bytes(s.data()); + u16string utf16 = wstring_convert, char16_t>{}.from_bytes(s.data()); #endif - mwSize dims[2] = { 1, static_cast(utf16.size()) }; - auto r = mxCreateCharArray(2, dims); - auto buf = mxGetChars(r); - int i = 0; + mwSize dims[2] = { 1, static_cast(utf16.size()) }; + auto r = mxCreateCharArray(2, dims); + auto buf = mxGetChars(r); + int i = 0; #ifdef _MSC_VER - for(wchar_t c : utf16) + for(wchar_t c : utf16) #else - for(char16_t c : utf16) + for(char16_t c : utf16) #endif - { - buf[i++] = static_cast(c); + { + buf[i++] = static_cast(c); + } + return r; } - return r; } string -- cgit v1.2.3