Skip to content

Instantly share code, notes, and snippets.

@MichaelBlume
Created August 12, 2016 23:47
Show Gist options
  • Save MichaelBlume/f9ed3a4f39f5e7c21385d3e56b8b6b34 to your computer and use it in GitHub Desktop.
Save MichaelBlume/f9ed3a4f39f5e7c21385d3e56b8b6b34 to your computer and use it in GitHub Desktop.
From 06a22bd44719b1753d522be0618b4c49c0c39642 Mon Sep 17 00:00:00 2001
From: Michael Blume <blume.mike@gmail.com>
Date: Fri, 12 Aug 2016 16:45:19 -0700
Subject: [PATCH] make submit work with octave 4.0
---
lib/jsonlab/loadjson.m | 4 ++--
lib/makeValidFieldName.m | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/jsonlab/loadjson.m b/lib/jsonlab/loadjson.m
index 42798c0..169aa61 100644
--- a/lib/jsonlab/loadjson.m
+++ b/lib/jsonlab/loadjson.m
@@ -494,7 +494,7 @@ global isoct
if(~isoct)
str=regexprep(str,'^([^A-Za-z])','x0x${sprintf(''%X'',unicode2native($1))}_','once');
else
- str=sprintf('x0x%X_%s',char(str(1)),str(2:end));
+ str=sprintf('x0x%X_%s',toascii(str(1)),str(2:end));
end
end
if(isempty(regexp(str,'[^0-9A-Za-z_]', 'once' ))) return; end
@@ -507,7 +507,7 @@ global isoct
pos0=[0 pos(:)' length(str)];
str='';
for i=1:length(pos)
- str=[str str0(pos0(i)+1:pos(i)-1) sprintf('_0x%X_',str0(pos(i)))];
+ str=[str str0(pos0(i)+1:pos(i)-1) sprintf('_0x%X_',toascii(str0(pos(i))))];
end
if(pos(end)~=length(str))
str=[str str0(pos0(end-1)+1:pos0(end))];
diff --git a/lib/makeValidFieldName.m b/lib/makeValidFieldName.m
index 4e0f34f..ea462dd 100644
--- a/lib/makeValidFieldName.m
+++ b/lib/makeValidFieldName.m
@@ -9,7 +9,7 @@ function str = makeValidFieldName(str)
if(~isoct)
str=regexprep(str,'^([^A-Za-z])','x0x${sprintf(''%X'',unicode2native($1))}_','once');
else
- str=sprintf('x0x%X_%s',char(str(1)),str(2:end));
+ str=sprintf('x0x%X_%s',toascii(str(1)),str(2:end));
end
end
if(isempty(regexp(str,'[^0-9A-Za-z_]', 'once' ))) return; end
@@ -22,7 +22,7 @@ function str = makeValidFieldName(str)
pos0=[0 pos(:)' length(str)];
str='';
for i=1:length(pos)
- str=[str str0(pos0(i)+1:pos(i)-1) sprintf('_0x%X_',str0(pos(i)))];
+ str=[str str0(pos0(i)+1:pos(i)-1) sprintf('_0x%X_',toascii(str0(pos(i))))];
end
if(pos(end)~=length(str))
str=[str str0(pos0(end-1)+1:pos0(end))];
--
2.9.3.603.ge0fe97b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment