The important thing about the linked question is in the title: "How to read a file into a variable in shell?" The answer is that you don't, not in Bash, since Bash can't handle the NUL bytes.
This can be worked around somewhat by encoding the file so that the literal NULs are represented some other way. That could be Base64 encoding (as
uuencode -m does), or URL encoding, or whatever. That's what the answer there does, it encodes the file using
uuencode to a "nicer" string with no NULs, then stores that in the variable
S. (A plain
S=$(cat file) would not work, it would try to store the file unchanged, with the NUL bytes and all.) The opposite action of decoding the file is also shown.
Usually, there's not much need for that, and one should probably try to avoid doing that. It's easier to process files by keeping them as files and processing them with external tools as necessary. But the question there was specifically about how to store a file (an arbitrary file) in a shell variable. In theory, there just might be some use for that. Maybe.
Though in your case, if you just want to print some fixed string, then
printf "a\0\n" > $filename or similar works just fine since any byte can be represented with the