utf8-decode 2.0.0

UTF-8 incremental decoding iterators.
Documentation
  • Coverage
  • 45.45%
    5 out of 11 items documented3 out of 6 items with examples
  • Size
  • Source code size: 28.96 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.73 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • timothee-haudebourg/utf8-decode
    4 1 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • timothee-haudebourg

UTF-8 decode

CI Crate informations License Documentation

This crates provides incremental UTF-8 decoders implementing the Iterator trait, wrapping around u8 bytes iterators.

It also provide the const-compatible try_decode_char to decode UTF-8 byte streams, even in const contexts.

Decoder

The [Decoder] iterator can be used, for instance, to decode u8 slices.

use utf8_decode::Decoder;
let bytes = [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33];

let decoder = Decoder::new(bytes.iter().cloned());

let mut string = String::new();
for c in decoder {
    string.push(c?);
}

println!("{}", string);

TryDecoder

The TryDecoder iterator can be used, for instance, to decode UTF-8 encoded files.

use utf8_decode::TryDecoder;
let file = File::open("examples/file.txt")?;

let decoder = TryDecoder::new(file.bytes());

let mut string = String::new();
for c in decoder {
    string.push(c?);
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.