print_bytes

Crates.ioprint_bytes
lib.rsprint_bytes
version2.0.1
sourcesrc
created_at2020-04-04 16:03:34.938423
updated_at2024-08-11 02:41:54.416134
descriptionPrint bytes as losslessly as possible
homepage
repositoryhttps://github.com/dylni/print_bytes
max_upload_size
id226307
size39,324
(dylni)

documentation

README

print_bytes

This crate allows printing broken UTF-8 bytes to an output stream as losslessly as possible.

Usually, paths are printed by calling Path::display or Path::to_string_lossy beforehand. However, both of these methods are always lossy; they misrepresent some valid paths in output. The same is true when using String::from_utf8_lossy to print any other UTF-8–like byte sequence.

Instead, this crate only performs a lossy conversion when the output device is known to require Unicode, to make output as accurate as possible. When necessary, any character sequence that cannot be represented will be replaced with REPLACEMENT_CHARACTER. That convention is shared with the standard library, which uses the same character for its lossy conversion functions.

GitHub Build Status

Usage

Add the following lines to your "Cargo.toml" file:

[dependencies]
print_bytes = "2.0"

See the documentation for available functionality and examples.

Rust version support

The minimum supported Rust toolchain version is currently Rust 1.74.0.

Minor version updates may increase this version requirement. However, the previous two Rust releases will always be supported. If the minimum Rust version must not be increased, use a tilde requirement to prevent updating this crate's minor version:

[dependencies]
print_bytes = "~2.0"

License

Licensing terms are specified in COPYRIGHT.

Unless you explicitly state otherwise, any contribution submitted for inclusion in this crate, as defined in LICENSE-APACHE, shall be licensed according to COPYRIGHT, without any additional terms or conditions.

Commit count: 73

cargo fmt