Watch
1
0
Fork
You've already forked rust-utf8-decode
0
No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Daniel Baumann 515c35276a
Updating to debhelper 14.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2026-06-14 12:50:40 +02:00
.github Merging upstream version 2.0.0. 2026-02-27 08:43:38 +01:00
debian Updating to debhelper 14. 2026-06-14 12:50:40 +02:00
examples Merging upstream version 2.0.0. 2026-02-27 08:43:38 +01:00
src Merging upstream version 2.0.0. 2026-02-27 08:43:38 +01:00
.cargo_vcs_info.json Merging upstream version 2.0.0. 2026-02-27 08:43:38 +01:00
.gitignore Adding upstream version 1.0.1. 2025-12-31 11:21:56 +01:00
Cargo.lock Merging upstream version 2.0.0. 2026-02-27 08:43:38 +01:00
Cargo.toml Merging upstream version 2.0.0. 2026-02-27 08:43:38 +01:00
Cargo.toml.orig Merging upstream version 2.0.0. 2026-02-27 08:43:38 +01:00
LICENSE-APACHE Adding upstream version 1.0.1. 2025-12-31 11:21:56 +01:00
LICENSE-MIT Adding upstream version 1.0.1. 2025-12-31 11:21:56 +01:00
README.md Merging upstream version 2.0.0. 2026-02-27 08:43:38 +01:00

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.