chardet

Crystal bindings for freedesktop.org's uchardet.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      chardet:
        github: elebow/chardet.cr
  2. Run shards install

Usage

require "chardet"

# ...

Chardet.detect(unknown_bytes)
# {encoding: "UTF-8"}

The only public interface is Chardet.detect(Bytes). It will return a hash with a single element:

Future versions of uchardet are likely to provide additional fields (see https://gitlab.freedesktop.org/uchardet/uchardet/-/issues/5#note_474963).

Contributing

  1. Fork it (https://github.com/elebow/chardet.cr/fork)
  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 a new Pull Request

Contributors