The function converts an integer representing an ASCII character code into a single character string
(Chr 1) return "\ 001"
(Chr 2) return "\ 002"
(Chr 3) return "\ 003"
What does (Chr (- 9 1)) return?
You may not hesitate to say "\008", but you are wrong and return "\ 010".
Similarly, (Chr 0) returns an empty character instead of "\ 000".
(Chr 11) return "\ 013"
In other words, the return value of this function does not have a one-to-one correspondence with the ASCII code. The number after the slash is not necessarily ASCII code, and some numbers do not have corresponding characters.
Therefore, using write-char and char functions to write binary files is very risky.
To write binary files, use the function write-byte, which is a reserved function.
The following are the test data, (Chr 0) to (Chr 127)
"" "\001" "\002" "\003" "\004" "\005" "\006" "\007" "\010" "\t" "\n" "\013" "\014" "\r" "\016" "\017" "\020" "\021" "\022" "\023" "\024" "\025" "\026" "\027" "\030" "\031" "\032" "\e" "\034" "\035" "\036" "\037" " " "!" "\"" "#" "$" "%" "&" "'" "(" ")" "*" "+" "," "-" "." "/" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" ":" "; " "<" "=" ">" "? " "@" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" "[" "\\" "]" "^" "_ " "`" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" "{" "|" "}" "~" "\177" "