BOMs can really drive you nuts!

In: Programming

14 Sep 2009

A BOM is an acronym for byte-order mark and is essentially used to tell the type of encoding of a data stream or file without having to explicitly specify it (for instance, through the content-type header in HTTP response).

I’d been having a particular issue with an API I built for a web application I’m managing and I just couldn’t figure out what was wrong until I got to using the API in an application that had HEX output.

So I put the application in debug mode and watched the communication stream. The API was supposed to return an integer value but instead, I noticed a EF BB BF hex sequence being prepended in the output. All attempts to remove this were futile.

Since I used the Symfony framework for the application, I suspected that it might be a bug and googled for a solution. The best answer I could get was to upgrade the framework, which I did but the problem persisted.

My big break came when I attempted to make another API call to a separate method that resulted in the correct output. While tracing the source of the problem, I traced it back to a php file that was incorrectly saved in the UTF-8 character encoding format; which was included when making the buggy API call. Opening and saving this file in ANSI format solved the problem.

So next time you run into a problem like this, make sure to check the encoding of your source files. Better still, you can use a tool like iconv to convert your files to the appropriate character encoding format.

Comment Form

About this blog

Tim Akinbo's Weblog is the personal weblog of Tim Akinbo. Here he discusses issues relating to technology. Special interests include the web, mobile technology and location based services.

Photostream

    Panel Session on Realizing Nigeria's Internet PotentialDelegates during Justin's Keynote PresentationBarCamp Attendees 1main hallmain hall 2main hall 3
  • Budzeg: I remember the days of mobile too... When we were building wapitis like it was going out of fashion. [...]
  • damiet: Tim i think the society has in some way showed us that technology, engineering, etc are male stuff. [...]
  • Tim: @Trae, my memory fails me. You\'re right I did start blogging in 2004 :) Hmm... so many years gone b [...]
  • trae_z: I started blogging late 2008. For one reason or the other, I lost the first two incarnations of m [...]
  • Tim: That would depend on what application is being built but I did read up uniPaaS and it's worth t [...]

Subscribe to this blog via email

Enter your email address: