encodings = [] not_utf8 = [] Dir.glob(Dir.new(".").path + '/**/*.rb') do |file| contents = File.read(file) detection = CharlockHolmes::EncodingDetector.detect(contents) encodings << detection[:encoding] not_utf8 << {file: file, detection: detection} unless "UTF-8" == detection[:encoding] end pp encodings.uniq pp not_utf8