From 23f14d69b20407f7bc552f686308447c41bee9e9 Mon Sep 17 00:00:00 2001 From: Qianqian Fang Date: Tue, 15 Oct 2019 14:00:55 -0700 Subject: [PATCH] minor updates to make msgpack to work on octave --- jdatadecode.m | 2 +- loadmsgpack.m | 8 ++++++-- nestbracket2dim.m | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/jdatadecode.m b/jdatadecode.m index 92e75a3..c1af646 100644 --- a/jdatadecode.m +++ b/jdatadecode.m @@ -103,7 +103,7 @@ if(iscell(data(j).(N_('_ArrayData_')))) data(j).(N_('_ArrayData_'))=cell2mat(cellfun(@(x) double(x(:)),data(j).(N_('_ArrayData_')),'uniformoutput',0)).'; end - ndata=cast(data(j).(N_('_ArrayData_')),data(j).(N_('_ArrayType_'))); + ndata=cast(data(j).(N_('_ArrayData_')),char(data(j).(N_('_ArrayType_')))); end iscpx=0; if(~isempty(strmatch(N_('_ArrayIsComplex_'),fn))) diff --git a/loadmsgpack.m b/loadmsgpack.m index f8ee362..a718b45 100644 --- a/loadmsgpack.m +++ b/loadmsgpack.m @@ -185,7 +185,11 @@ end function [str, idx] = parsestring(len, bytes, idx) - str = native2unicode(bytes(idx:idx+len-1)', 'utf-8'); + if(~isoctavemesh) + str = native2unicode(bytes(idx:idx+len-1)', 'utf-8'); + else + str = bytes(idx:idx+len-1)'; + end idx = idx + len; end @@ -223,7 +227,7 @@ out = struct(); for n=1:len [key, idx] = parse(bytes, idx); - [out.(valid_field(key)), idx] = parse(bytes, idx); + [out.(valid_field(char(key))), idx] = parse(bytes, idx); end end diff --git a/nestbracket2dim.m b/nestbracket2dim.m index 1562e3f..c25ffc4 100644 --- a/nestbracket2dim.m +++ b/nestbracket2dim.m @@ -10,7 +10,7 @@ % % input: % str: a string-formatted JSON array using square-brackets for enclosing -% elements and comma a separator between elements +% elements and comma as separators between elements % brackets: (optional), a string of length 2, with the first character % being the opening token and the 2nd being the closing token. % if not given, brackets is set to '[]' to find matching square-brackets;