How can I create an empty associative array, then fill it to map strings to strings?
Which of the issues below are bugs and how can I report them?
The associations I want to have to do are related to escaping strings so non-printable characters are HEX-encoded:
Code: Select all
"\00"->"\\00"
"\01"->"\\01"
..
"\1F"->"\\1F"
"\7F"->"\\7F"
..
"\FF"->"\\FF"
Below is what fails and how. I've included a `/system script environment remove 0` (on a system without any global variables set) in-between all examples.
Fails because the initial value isn't parsed correctly (and has a trailing double-quote so `\00` isn't associated):
Code: Select all
:global convert {"\00"="\\00"}
:set ($convert->"\7F") "\\7F"
:set ($convert->"\81") "\\81"
:put [/system script environment print]
# NAME VALUE
0 convert \81=\81;\00"=\00;\7F=\7F
:put [:typeof $convert]
array
:put "$convert"
?=\81;"=\00;=\7F
:put ($convert->"\00")
:put ($convert->"\81")
\81
:put ($convert->"f")
Code: Select all
:global convert {"\81"="\\81"}
:set ($convert->"\7F") "\\7F"
:set ($convert->"\00") "\\00"
:put [/system script environment print]
# NAME VALUE
0 convert \81"=\81;\00=\00;\7F=\7F
:put [:typeof $convert]
array
:put "$convert"
?"=\81;=\00;=\7F
:put ($convert->"\00")
\00
:put ($convert->"\81")
:put ($convert->"f")
Code: Select all
:global convert value=
:set ($convert->"\00") "\\00"
:set ($convert->"\7F") "\\7F"
:set ($convert->"\81") "\\81"
:put [/system script environment print]
# NAME VALUE
0 convert
:put [:typeof $convert]
nothing
:put "$convert"
:put ($convert->"\00")
:put ($convert->"\81")
:put ($convert->"f")
Code: Select all
:global convert {"\01"="\\01"}
:set ($convert->"\7F") "\\7F"
:set ($convert->"\81") "\\81"
:put [/system script environment print]
# NAME VALUE
0 convert \81=\81;\01"=\01;\7F=\7F
:put [:typeof $convert]
array
:put "$convert"
?=\81;"=\01;=\7F
:put ($convert->"\00")
:put ($convert->"\81")
\81
:put ($convert->"f")
Code: Select all
:global convert {}
syntax error (line 1 column 19)
:set ($convert->"\00") "\\00"
:set ($convert->"\7F") "\\7F"
:set ($convert->"\81") "\\81"
:put [/system script environment print]
# NAME VALUE
:put "$convert"
:put ($convert->"\00")
:put ($convert->"\81")
:put ($convert->"f")
Code: Select all
:global convert {"o"="o","f"="f","b"="a"}
:put [/system script environment print]
# NAME VALUE
0 convert o=o;true;false
:put [:typeof $convert]
array
:put "$convert"
o=o;true;false
:put ($convert->"\00")
:put ($convert->"\81")
:put ($convert->"f")
Code: Select all
:global convert {"##"=""}
:set ($convert->"\00") "\\00"
:set ($convert->"\7F") "\\7F"
:set ($convert->"\81") "\\81"
:put [/system script environment print]
# NAME VALUE
0 convert \81=\81;\00=\00;##=;\7F=\7F
:put [:typeof $convert]
array
:put "$convert"
?=\81;=\00;##=;=\7F
:put ($convert->"\00")
\00
:put ($convert->"\81")
\81
:put ($convert->"f")
--jeroen