brianmario/charlock_holmes — pull request #68 by brianmario (2014-06-03 19:50:10+00:00)
Title: Add and use a Ruby-compatible encoding lookup table

The encoding names returned from `CharlockHolmes::EncodingDetector.detect` come directly from ICU's encoding detection API. Some of which don't directly map to supported encodings in Ruby. That means if you try to tag a string in ruby (with `String#force_encoding`) with an encoding name like "ISO-2022-CN" - Ruby would raise an exception because it's not supported by Ruby's encoding API.

This adds a Ruby-compatible encoding lookup table - `CharlockHolmes::EncodingDetector.encoding_table` - and uses it to set a new `:ruby_encoding` key to be returned from `CharlockHolmes::EncodingDetector.detect` when an encoding is detected. This is also used in the String helper methods (`String#detect_encoding`) to ensure a Ruby-compatible encoding is used.

/cc @josh @adelcambre @alindeman @ymendel