Byte Order Mark in layouts

Hi all,

I had a rails project ported from a java app that was perplexing me.
Everything was running fine, except that it wouldn’t validate with the
W3C HTML validator - it kept saying that there was a invalid character
in there and failing.

Up until a few days ago, I had no idea what a BOM or Byte Order Mark
was. Apparently, many editors write a few bytes at the beginning of a
UTF-encoded file so they know how to handle it. I found out about it
on a totally unrelated project and just now realized it might be my
culprit in this case. Sure enough, it was there in the layout, and
taking it out with a hex editor solved my problems.

The byte sequence that was showing up was “c3 af c2 bb c2 bf 0a”, but
the BOM in that particular file was “ef bb bf” - how was it getting
transformed (by Rails?), and why? This was on Rails 1.1.2. I assume
web browsers are smart enough to deal with BOMs if they are in fact
valid BOMs, but this one wasn’t - thus the problem.

Has anyone else had a problem similar to this? Should rhtml files just
not be Unicode-encoded or what? Or at least it seems that they
shouldn’t have a BOM, or am I missing something?

Thanks!

-Pawel

P.S. - I had long ago given up on the W3C validation problem and was
just patching the frozen gems when I came upon the solution. So for me
at least, the vulnerability and patch were a good thing!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs