#unsafe #detect #read #wrapper #open #interface #deprecated #free #issue #pure

deprecated sys uchardet-sys

Low-level, unsafe interface to uchardet encoding detector

11 releases (4 stable)

Uses old Rust 2015

2.0.3 Nov 28, 2017
2.0.2 Nov 14, 2017
2.0.0 Mar 18, 2017
2.0.0-pre.1 Oct 30, 2016
0.0.2 Nov 20, 2014
Download history 68/week @ 2022-06-04 5/week @ 2022-06-11 7/week @ 2022-06-18 21/week @ 2022-06-25 4/week @ 2022-07-02 14/week @ 2022-07-09 14/week @ 2022-07-16 25/week @ 2022-07-23 29/week @ 2022-07-30 20/week @ 2022-08-06 15/week @ 2022-08-13 6/week @ 2022-08-20 235/week @ 2022-08-27 1448/week @ 2022-09-03 3507/week @ 2022-09-10 863/week @ 2022-09-17

6,056 downloads per month
Used in uchardet



C++ 7K SLoC // 0.3% comments Python 1K SLoC // 0.7% comments C 72 SLoC // 0.4% comments Rust 45 SLoC // 0.3% comments Shell 22 SLoC

Latest version License Build Status Build status Documentation

Deprecated in favor of chardet, which is pure Rust. If you have use-case for this code, please feel free to open an issue. Simple PRs will still be read, and possibly accepted.

Attempts to detect the character encoding of raw text using the uchardet library.


// At the top of the file.
extern crate uchardet;
use uchardet::detect_encoding_name;

// Inside a function.

If you also would also like to detect the language used in the decoded text, see rust-cld2.

Getting uchardet (usually optional)

If you wish, you may install uchardet using your system package manager. For example, under Ubuntu, you can run:

sudo apt-get install libuchardet-dev

If you skip this step, Cargo will attempt to compile uchardet from the bundled source code instead. This should work if you have an appropriate g++ (or MSVC) compiler installed, as well as cmake. We test this build on Linux, OS X and Windows (both MinGW and MSVC) using Travis CI.


As always, pull requests are welcome! Please keep any patches as simple as possible and include unit tests; that makes it much easier for me to merge them.

If you want to get the C/C++ code building on another platform, please see uchardef-sys/build.rb and this build script guide. You'll probably need to adjust some compiler options. Please don't hesitate to ask questions; I'd love for this library to support more platforms.

In your first commit message, please include the following statement:

I dedicate any and all copyright interest in my contributions to this project to the public domain. I make this dedication for the benefit of the public at large and to the detriment of my heirs and successors. I intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

This allows us to keep the library legally unencumbered, and free for everyone to use.

Contributors include:

  • Boris-Chengbiao Zhou. Support for newer upstream uchardet libraries and Microsoft Windows, plus the error-chain conversion.
  • Wesley Moore. Fixes for Rust beta 2 and OS X.

Thank you very much for your contributions!


New code in the rust-uchardet library is released into the public domain, as described in the UNLICENSE file. However, several pre-existing pieces have their own licenses:

  • The uchardet C++ library include in uchardet-sys/uchardet via a git submodule is distributed under the Mozilla Public License 1.1.