Skip to content

Instantly share code, notes, and snippets.

@snaka
Created July 2, 2014 12:04
Show Gist options
  • Save snaka/0c16fe5882e2793f17f2 to your computer and use it in GitHub Desktop.
Save snaka/0c16fe5882e2793f17f2 to your computer and use it in GitHub Desktop.
BOM無しUTF-8のファイルをBOM付きで一括で保存し直す ref: http://qiita.com/snaka/items/2e2ec9961834f6629d69
dirs = ["./trunk/unity/Assets/Source/**/*.cs", "./trunk/unity/Assets/Editor/**/*.cs"]
dirs.each do |dir|
Dir.glob(dir).each do |f|
next unless File.file?(f)
hoge = open(f)
hoge.binmode
begin
if hoge.read(3).unpack("h*")[0] != "febbfb"
puts f.to_s #+ " is *NOT* BOM file"
end
rescue
end
end
end
$ for f in $(ruby bomcheck.rb); do vim -c "set fenc=utf-8 bomb" -c "x" $f; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment