Posts

Showing posts from November, 2015

How to remove the bom from http response

What is bom? The byte order mark ( BOM ) is a Unicode character used to signal the endianness ( byte order ) of a text file or stream. Its code point is U+FEFF. BOM use is optional, and, if used, should appear at the start of the text stream. How to know the response is bom encoded or not: To know whether the response is bom encoded or not you just need to see the response if the response look something like this: BASE_URL = 'http://www.claritin.com/webservice/allergyforecast.php?zip=' resp = Net :: HTTP .get_response( URI ( " #{ BASE_URL }10007 " )).body "\xEF\xBB\xBF\"[{\\\"pollenForecast\\\":{\\\"zip\\\":\\\"10007\\\",\\\"city\\\":\\\"NEW YORK\\\",\\\"state\\\":\\\" NY\\\",\\\"forecast\\\":[1.1,0.1,0.8,0.6],\\\"pp\\\":\\\"Mixed Trace.\\\",\\\"timestamp\\\":\\\"11\\/14\\/2015 12:00:00 AM\\\"},\\\"weatherForecast\\\&qu