#bytes #osstr #path #print #windows

print_bytes

Print bytes as losslessly as possible

6 releases (3 breaking)

0.4.2 Dec 7, 2020
0.4.1 Oct 22, 2020
0.3.1 Jun 25, 2020
0.2.0 Apr 22, 2020
0.1.0 Apr 4, 2020

#81 in Operating systems

Download history 41/week @ 2021-04-04 42/week @ 2021-04-11 61/week @ 2021-04-18 62/week @ 2021-04-25 94/week @ 2021-05-02 39/week @ 2021-05-09 32/week @ 2021-05-16 17/week @ 2021-05-23 17/week @ 2021-05-30 39/week @ 2021-06-06 32/week @ 2021-06-13 15/week @ 2021-06-20 18/week @ 2021-06-27 18/week @ 2021-07-04 18/week @ 2021-07-11 23/week @ 2021-07-18

170 downloads per month
Used in 2 crates

MIT/Apache

21KB
384 lines

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 = "0.4"

See the documentation for available functionality and examples.

Rust version support

The minimum supported Rust toolchain version is currently Rust 1.36.0.

However, the "min_const_generics" and "specialization" features require a nightly compiler.

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.

Dependencies

~27KB