Created
July 2, 2014 12:04
-
-
Save snaka/0c16fe5882e2793f17f2 to your computer and use it in GitHub Desktop.
BOM無しUTF-8のファイルをBOM付きで一括で保存し直す ref: http://qiita.com/snaka/items/2e2ec9961834f6629d69
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
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 |
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
$ 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