From ef9d7d498718d6a9707c0e7a2687f50da76a81e2 Mon Sep 17 00:00:00 2001 From: Mus M Date: Sat, 5 Nov 2016 16:27:41 -0400 Subject: [PATCH] Use transcode for string convert to Julia --- README.md | 6 ++---- src/mxarray.jl | 7 ++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d278da7..b2d6e56 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,9 @@ By default, `MATLAB.jl` uses the MATLAB installation with the greatest version n ### Windows -1. Start a Command Prompt as an Administrator. +1. Start a Command Prompt as an Administrator and enter `matlab /regserver`. -2. Enter `matlab /regserver` in the command prompt. - -3. From Julia run: `Pkg.add("MATLAB")` +2. From Julia run: `Pkg.add("MATLAB")` ### Linux diff --git a/src/mxarray.jl b/src/mxarray.jl index d824b15..2fae6bd 100644 --- a/src/mxarray.jl +++ b/src/mxarray.jl @@ -60,6 +60,7 @@ typealias MxNum Union{MxRealNum, MxComplexNum} typealias mwSize UInt typealias mwIndex Int +typealias mxChar UInt16 typealias mxClassID Cint typealias mxComplexity Cint @@ -639,11 +640,7 @@ function jstring(mx::MxArray) if !(classid(mx) == mxCHAR_CLASS && ((ndims(mx) == 2 && nrows(mx) == 1) || is_empty(mx))) throw(ArgumentError("jstring only applies to strings (i.e. char vectors).")) end - len = ncols(mx) + 1 - tmp = Array(UInt8, len) - ccall(_mx_get_string, Cint, (Ptr{Void}, Ptr{UInt8}, mwSize), mx, tmp, len) - pop!(tmp) - String(tmp) + return transcode(String, unsafe_wrap(Array, Ptr{mxChar}(data_ptr(mx)), ncols(mx))) end function jdict(mx::MxArray)