Skip to content

Instantly share code, notes, and snippets.

@jedfoster
Last active December 14, 2015 02:59
Show Gist options
  • Save jedfoster/5017524 to your computer and use it in GitHub Desktop.
Save jedfoster/5017524 to your computer and use it in GitHub Desktop.
Strip a BOM from a file.
# $ rake unbomb PATH/TO/FILE
task :unbomb do
file = ARGV.last
string = File.open(file, 'r:utf-8').read().encode!('utf-8')
File.open(file, 'w:utf-8') { |f| f.write string.sub!(/\uFEFF/, '') }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment