Created
October 24, 2012 17:56
-
-
Save jedfoster/3947705 to your computer and use it in GitHub Desktop.
Thor task to remove BOM from UTF-8 files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove BOM from UTF-8 file | |
def unbomb(file) | |
string = File.open(file, 'r:utf-8').read().encode!('utf-8') | |
if string.start_with?("\uFEFF") | |
string.sub!(/\uFEFF/, '') # Remove the BOM | |
create_file file, string, {:force => true, :verbose => false} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment