#!/usr/bin/ruby
require 'nkf'
ARGV.each {|filename|
print filename + ": "
f = open(filename, "rb")
content = f.read
if content.index("\r\n")
lb = "CRLF"
elsif content.index("\n")
lb = "LF"
elsif content.index("\r")
lb = "CR"
else
lb = "?"
end
print lb + " - "
guess = NKF::guess(content)
case guess
when NKF::JIS
puts "JIS"
when NKF::EUC
puts "EUC"
when NKF::SJIS
puts "SJIS"
when NKF::BINARY
puts "BINARY"
when NKF::UNKNOWN
puts "UNKNOWN"
when NKF::ASCII
puts "ASCII"
when NKF::UTF8
puts "UTF8"
when NKF::UTF16
puts "UTF16"
end
f.close
}