The below fails: it doesn't like the `("\0".$hexChar)` construct.
So: how do I convert a string containing the characters "\", "0" and "1" (where "0" and "1" are dynamically generated) so it parses as "\01"?
Code: Select all
:global convert ({});
#:set ($convert->"\00") "\\00"
:set ($convert->"\7F") "\\7F"
:set ($convert->"\81") "\\81"
:local hexChars "01234567890ABCDEF"
:local groupChars "01890ABCDEF"
:for hexCharsIndex from=0 to=([:len $hexChars] - 1) do={
:local hexChar [:pick $hexChars $hexCharsIndex]
:set ($convert->("\0".$hexChar)) ("\\0".$hexChar)
}