Project

charlotte

0.0
No commit activity in last 3 years
No release in over 3 years
A simple (but fast!) character set encoding/binary detector and auto-converter for common encodings (UTF-8/16/32, ISO-8859-1, MacRoman, etc.). Extends String with String.detect_encoding, String.autoencode.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Charlotte

Ruby's "econv" (1.9.3+) implements native character set conversion functionality, but it lacks the ability to detect encodings. This gem is a small, pure Ruby character set encoding detection library for quickly detecting and automatically converting to UTF-8. The main thrust is to be lightweight and fast, rather that pedantic and exhaustive. It covers common encodings (UTF-8/16/32, ISO-8859-1, MacRoman, etc.), and returns rare legacy encodings and binary files as "ASCII-8BIT" / "BINARY", possibly for further processing if needed. It was primarily written as a potential alternative to charlock_holmes (used in linguist), which leverages the ICU library via a C++ extention, and rchardet, which, while exhaustive, is quite slow.

Pull requests, contributions, optimization, other ideas, greatly welcomed.

Install

gem install charlotte