Skip to content

Conversation

@simonster
Copy link
Member

Includes test from #78, which passes since we transcode the strings properly.

mx = MxArray(pm)
ccall(:memcpy, Ptr{Void}, (Ptr{Void}, Ptr{Void}, UInt), data_ptr(mx), utf16string,
length(utf16string)*sizeof(UInt16))
mx
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return mx (trying to be consistent)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but not exactly consistent elsewhere in the file.


# char arrays and string

function mxarray(s::String)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

pm = ccall(_mx_create_string, Ptr{Void}, (Ptr{UInt8},), s)
MxArray(pm)
utf16string = transcode(UInt16, s)
pm = ccall(_mx_create_char_array, Ptr{Void}, (mwSize, Ptr{mwSize},), 2,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ptr is not actually so clear, since this is a Ptr{Void} to the MATLAB object and not the pointer to the data. pm is the variable name used by the other functions like this in the file.

pm = ccall(_mx_create_char_array, Ptr{Void}, (mwSize, Ptr{mwSize},), 2,
_dims_to_mwSize((1, length(utf16string))))
mx = MxArray(pm)
ccall(:memcpy, Ptr{Void}, (Ptr{Void}, Ptr{Void}, UInt), data_ptr(mx), utf16string,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function mxarray(s::String)
pm = ccall(_mx_create_string, Ptr{Void}, (Ptr{UInt8},), s)
MxArray(pm)
utf16string = transcode(UInt16, s)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should prolly use mxChar here

_dims_to_mwSize((1, length(utf16string))))
mx = MxArray(pm)
ccall(:memcpy, Ptr{Void}, (Ptr{Void}, Ptr{Void}, UInt), data_ptr(mx), utf16string,
length(utf16string)*sizeof(UInt16))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mxChar here too prolly

@simonster simonster merged commit 2202c9b into master Nov 8, 2016
@simonster simonster deleted the sjk/fix-string-encoding branch November 8, 2016 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants