bom snippets

Removing BOM with Ruby 1.9

Tagged bom, ruby  Languages ruby

Removing the BOM with Ruby 1.9:

body = File.open(file, "r:bom|utf-8").read()
File.open(file, 'w') do |xass| 
  xass << body
end

In Ruby 1.8 you could do something like this:

body = body[3..-1] if body[0..2] == "\357\273\277"