Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^2: UTF-8 text files with Byte Order Mark

by muba (Priest)
on Feb 13, 2007 at 20:05 UTC ( #599762=note: print w/ replies, xml ) Need Help??

in reply to Re: UTF-8 text files with Byte Order Mark
in thread UTF-8 text files with Byte Order Mark

Patient: "Doctor, it hurts when I do this."
Doctor: "So don't do it!"

Easy to say, of course, but what if the program one of my users uses stores that BOM anyway? Besides, as pointed out, a BOM in a utf-8 file *are* valid so I feel I should support it. Look, if the user was toying around with malformed files I'd be more than happy to tell him to get that fixed :D but apparently he's doing what he righteously thinks is righs.

  • Comment on Re^2: UTF-8 text files with Byte Order Mark

Replies are listed 'Best First'.
Re^3: UTF-8 text files with Byte Order Mark
by ikegami (Pope) on Feb 13, 2007 at 20:36 UTC

    a BOM in a utf-8 file *are* valid

    "!" in an ASCII file is also valid. But if you place a "!" at the start of your Perl program, it probably will not compile. It is a malformed file, not from a UNICODE perspective, but from your parser's perspective.

    I provided two alternatives (removing the BOM and File::BOM) that will work with your broken tools (i.e. tools that add undesirable character to the files you edit). I'd go with them since allowing the BOM is surely a good thing.

      Ouch. I'm afraid I used the wrong tone in my previous reply. You see, I am now removing that BOM myself (as you can read below). I never meant to attack or critisize you. In fact, I much appreciate your input!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://599762]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2016-07-27 07:41 GMT
Find Nodes?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?

    Results (242 votes). Check out past polls.