Crates.io | binaryornot |
lib.rs | binaryornot |
version | 1.0.0 |
source | src |
created_at | 2019-06-11 19:59:51.749243 |
updated_at | 2019-06-11 19:59:51.749243 |
description | Detect whether a file is binary or not |
homepage | |
repository | https://github.com/keirlawson/binaryornot |
max_upload_size | |
id | 140461 |
size | 513,962 |
A Rust port of binaryornot, letting you detect whether a file is binary or text.
Add the following to your cargo.toml
:
[dependencies]
binaryornot = "1.0"
use binaryornot;
if binaryornot::is_binary("/path/to/some/file").expect("unable to read file") {
println!("a binary!");
}
Due to relying on the encoding crate for detecting different possible text encodings, UTF-32 will not be correctly detected as text, unlike in the original Python binaryornot implementation.
As indicated in the cargo.toml, this library can be consumed either under the MIT or Apache 2.0 licences. However, it should be noted that one of its dependencies, chardet, is licenced under the LGPL, meaning that any program statically linking it must also be distributed under the LGPL.