3 ms·
Ok, but everything handles the UTF-8 "BOM" just fine. Adding it only causes problems when you ./file.sh that has a BOM, and haven't setup your binfmt_misc magi
by jrockway 17y ago
Ok, but everything handles the UTF-8 "BOM" just fine. Adding it only causes problems when you ./file.sh that has a BOM, and haven't setup your binfmt_misc magic properly. Fix that, and it works fine.
- jmillikin 17y agoOk, but everything handles the UTF-8 "BOM" just fine. For small values of "everything". I can't even count the number of bizarre errors I encounter, only to discover that one of the files I'm working on has been corrupted by somebody carelessly using Notepad. Usually it's not obvious what's going on -- the error will be something like "Error parsing file: illegal byte before start of message body", which provides not much help when it's 23:30 and I'm staring at a text editor wondering what the hell byte it's talking about.
- pak 17y agoAnd therein lies the insanity that is a BOM: it's a character that's meant to be invisible, even to your UTF-8 capable text editor. With this in mind, it's not clear what is supposed to be able to view or edit this character, short of a hex editor. Somebody else mentioned even cat ignores it; how are you supposed to easily tell that it's there or not? IMHO a BOM is completely ridiculous to have on a UTF-8 file, because UTF-8 has no ambiguity over endian-ness that a BOM needs to resolve, and it breaks the principle that UTF-8 can serve as ASCII when all the codepoints <0x7F. Is there any point to using it in UTF-8 besides pain, suffering, and "well UTF-16 and UTF-32 have it"? The answer, straight from the horse's mouth. http://www.unicode.org/versions/Unicode5.0.0/ch02.pdf http://www.unicode.org/versions/Unicode5.0.0/ch02.pdf , pg. 36 "Use of a BOM is neither required nor recommended for UTF-8, but may be encountered in contexts where UTF-8 data is converted from other encoding forms that use a BOM or where the BOM is used as a UTF-8 signature." That's right, the UTF-8 BOM is neither required nor recommended. I rest my case.
- vlisivka 17y ago"cat -v" saved lot of my time in cases like that. I had similar problem with nbsp, until I moved nbsp from second level (shift+space) to third level in XKB configuration in my Gnome/Fedora/Linux.
- jsankey 17y agoIt would be nice if everything did, but some major pieces of software don't. For example, the Java I/O library: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058 This is one of those problems that also won't be fixed to preserve (bug) compatibility.
- jrockway 17y agoOK, but most of the UNIX toolchain handles it just fine. Even cat knows not to output the BOM to the terminal :) Emacs and Perl are also fine. What more do you need?
- Daniel_Newby 17y agoDoes cat really? The BOM character just happens to also be the "zero-width non-breaking space", so it should be invisible when printed.
- rbanffy 17y agoDespite running under a form of Unix, my iPod is crippled in that I cannot run a "cat nasty_notepad_corrupted_file.txt | od" to check. Should be simple.
- arethuza 17y agoThat isn't the case - I have an example right here of a large expensive application that uses an old Java XML parser (some ancient version of Xerces I think) that gets very upset if you feed it an XML document that has a BOM.
- rbanffy 17y agoIt's always easy to upset an XML parser...