UTF-32 doesnβt completely solve this either, because grapheme clusters.
More generally, every code unit in the file has to have the form 00xxyy00, and the possible values for xx and yy must be in the range 0 thru 16, so there are only 17*17-1 = 288 unicode code points that can possibly occur in a endianness-ambiguous string/file.
And out of those, you have confusions like "Δ" (U+0100 LATIN CAPITAL LETTER A WITH MACRON) versus "π" (U+10000 LINEAR B SYLLABLE B008 A) or "π " (U+20000) versus "Θ" (U+200), most of which can only happen if you have no idea what language you're expecting. (Some, like "π" (U+10100 AEGEAN WORD SEPARATOR LINE), are the same regardless.)
Whereas here's a valid bash script:
ββ βΌζζ€ζΈβΌζζηζ ΰ¨ηηζζΌ ζ€ζΰ¨β 2>/dev/null || true
echo "Hello, World!" # ΰ¨
(You can almost do this with C/C++ as well, but something needs to #define "βΌβΌ" as "int" for it to work properly, and then only if the compiler accepts non-ascii characters (namely "βΌ" aka U+2F00 KANGXI RADICAL ONE) in identifiers.)