# writing bytes to stdout by numeric value
writebytes() { printf %b "$(printf \\\\%03o "$@")"; }
# writebytes 65 66 67 10

# this function allows specification of byte values in base 8, 10, or 16.
# octal and hex values must be prefixed with 0 or 0x, respectively.
# if you want the arguments to always be treated as octal, for example
# when processing values read by the previous trick for reading binary data,
# try this version:

writeoct() { printf %b "$(printf \\\\%s "$@")"; }

# be aware that it will break if your octal values are larger than 3 digits,
# so don't prepend a leading 0.
# following version is much slower but avoids that problem:

writeoct2() { printf %b "$(printf \\%03o "$(printf 0%s\  "$@")")"; }
