FileInfo

Gem Version Build Status Code Climate Coverage Status Dependency Status

FileInfo detects encoding from strings and files using the wonderful Unix file command.

Installation

Add this line to your application's Gemfile:

gem 'fileinfo'

And then execute:

$ bundle

Or install it yourself as:

$ gem install fileinfo

Usage

Use FileInfo.parse with a string:

FileInfo.parse('foo bar baz').encoding # => #<Encoding:US-ASCII>
FileInfo.parse('föø bår bàz').encoding # => #<Encoding:UTF-8>

Use FileInfo.load with a filename:

filename = '/Users/rafbm/Downloads/some_crap_coming_from_windows.csv'
FileInfo.load(filename).encoding # => #<Encoding:ISO-8859-1>

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

© 2013 Rafaël Blais Masson. FileInfo is released under the MIT license.