Why does clang generate unintelligible text when redirected?

It has nothing to do with codepages/encoding. Your output isn't plain text. It contains the sequences like [0;1;32m. These strings (there is a, not shown, [escape] character as well before each of these) are instructions to the terminal to show text bold, italics, in various colors, etc. This results in easier to read output, if your terminal supports it.

There should be an option to tell clang not to try to beautify the output, but use plain text instead. Check the manual. (I don't have one handy, so I can't tell you what the proper command would be.)

Alternatively, instead of removing the colours from the output, you can view the coloured output in your terminal by using the raw option of less

less -r output.txt

Those characters, such as [0;33m look like terminal output control to me. They're part of a set of escape sequences that is frequently used for applying colors to text in the terminal. In its raw state like this it is also often used for applying color to the bash prompt itself - Here's what I've been using in .bashrc for years on all of my machines:

export PS1='\[\033[1;33m\]\u\[\033[1;35m\]@\[\033[1;32m\]\h\[\033[0;36m\]\w\[\033[1;37m\]\$ \[\033[0;37m\]'

(Most think it's ugly, but I like it).

See if you are able to find a switch to remove any color coding or the like from the output of your commands and see if that helps.