#utf-8 #length #character #width

no-std utf8-width

To determine the width of a UTF-8 character by providing its first byte

9 releases

0.1.8 Nov 23, 2025
0.1.7 Nov 20, 2023
0.1.6 Mar 19, 2022
0.1.5 Apr 22, 2021
0.1.3 Jun 27, 2020

#177 in Encoding

Download history 716099/week @ 2025-08-13 631154/week @ 2025-08-20 599751/week @ 2025-08-27 666514/week @ 2025-09-03 602989/week @ 2025-09-10 602658/week @ 2025-09-17 617926/week @ 2025-09-24 600065/week @ 2025-10-01 568426/week @ 2025-10-08 556104/week @ 2025-10-15 608059/week @ 2025-10-22 635820/week @ 2025-10-29 617367/week @ 2025-11-05 625060/week @ 2025-11-12 639331/week @ 2025-11-19 353137/week @ 2025-11-26

2,343,449 downloads per month
Used in 1,622 crates (10 directly)

MIT license

5KB
59 lines

UTF-8 Width

CI

To determine the width of a UTF-8 character by providing its first byte.

References: https://tools.ietf.org/html/rfc3629

Examples

assert_eq!(1, utf8_width::get_width(b'1'));
assert_eq!(3, utf8_width::get_width("".as_bytes()[0]));

Benchmark

cargo bench

Crates.io

https://crates.io/crates/utf8-width

Documentation

https://docs.rs/utf8-width

License

MIT

No runtime deps