Hi Developer,
Thank you for your great works on reading toml file using matlab.
Problem
When I use your project for reading "*.toml" file, I encounter the error as follows
>> fname = 'example.toml';
>> decode(fname);
Error: File: TOML_MATLAB_ROOT/toml/private/consume_comment.m Line: 10 Column:
40
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax
error. To construct matrices, use brackets instead of parentheses.
Error in decode (line 17)
toml_str = consume_comment(toml_str);
A Line 10 in consume_comment.m contains char(0xD). My current matlab version is 2018a. It seems that matlab version is not a source of problem.
What is meaing of char(0xD)? It seems that you convert the ASCII digit to text format (https://www.programming-algorithms.net/article/40286/ASCII-table).
For example, 0xD means CR(Carriage Return) in text.
if c == newline || (c == char(0xD) && idx < numel(out) && out(idx+1) == newline)
Solution
I find a solution for above problem.
It seems that function hex2dec in matlab (version < R2020a) does not support prefix 0x. For example, hex2dec('0xFF') is equal to hex2dec('FF').
hex2dec('FF') # supported since R2006a
hex2dec('0xFF') # supported since R2020a
Finally, the code should be changed to
if c == newline || (c == char(hex2dec('D')) && idx < numel(out) && out(idx+1) == newline)
Best regards,
Inwoo
Hi Developer,
Thank you for your great works on reading toml file using matlab.
Problem
When I use your project for reading "*.toml" file, I encounter the error as follows
A Line 10 in
consume_comment.mcontainschar(0xD). My current matlab version is2018a. It seems that matlab version is not a source of problem.What is meaing of
char(0xD)? It seems that you convert the ASCII digit to text format (https://www.programming-algorithms.net/article/40286/ASCII-table).For example,
0xDmeansCR(Carriage Return)in text.Solution
I find a solution for above problem.
It seems that function
hex2decin matlab (version <R2020a) does not support prefix0x. For example,hex2dec('0xFF')is equal tohex2dec('FF').Finally, the code should be changed to
Best regards,
Inwoo