GithubHelp home page GithubHelp logo

cchardet-ruby's Introduction

cchardet

Ruby bindings for freedesktop.org's uchardet (https://gitlab.freedesktop.org/uchardet/uchardet).

By default, this gem depends on the system uchardet. Alternatively, it can build the unreleased wip/Jehan/improved-API branch of uchardet as a native extension. Note that uchardet's license terms may differ from those of this gem.

Installation

System uchardet

Add this line to your application's Gemfile:

gem "cchardet"

And then execute:

bundle install

Or install it yourself as:

gem install cchardet

Unreleased branch as native extension

When using bundler:

bundle config set --global build.cchardet --with-unreleased-uchardet
bundle install

When using gem directly:

gem install cchardet -- --with-unreleased-uchardet

Usage

require "cchardet"

CChardet.detect(unknown_bytes)
# released uchardet:
#   { encoding: "UTF-8" }
# unreleased native extension:
#   { encoding: "UTF-8", confidence: 1.0, language: nil }

The only public interface is CChardet.detect, which takes a sequence of bytes.

When using a released version of uchardet, it will return a hash with a single element, encoding, indicating the detected encoding of the byte stream. Future versions of uchardet are likely to provide additional fields (see https://gitlab.freedesktop.org/uchardet/uchardet/-/issues/5#note_474963).

When using the unreleased native extension, it will return an array of hashes having three elements:

  • encoding – Detected encoding of the byte stream
  • confidence – Confidence of the encoding value
  • language – Detected language, if known

The hashes are ordered by descending confidence.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/elebow/cchardet.

License

MIT License.

Note that uchardet, which may be compiled as a native extension, is covered by its own license.

cchardet-ruby's People

Watchers

 avatar  avatar

cchardet-ruby's Issues

RubyGems and Github naming mismatch

Hey,

My name is Maciej Mensfeld and I run a research security project called diffend.io.

I've noticed, that you have a mismatch between the repo name on GitHub (https://github.com/elebow/cchardet-ruby) and the RubyGems one (https://rubygems.org/gems/cchardet).

This mismatch has been recently used as a brandjacking base for libraries like yours thus I took courtesy and "booked" it for you (if you want).

If not, I'll just keep it as it is, protecting the GH_NAME :)

If you want to transfer the ownership just please reach out to me.

Have a great day and thank you

ref https://rubygems.org/gems/cchardet https://github.com/elebow/cchardet-ruby

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.