#utf-8 #width #character #unicode-width #unicode-characters #length

no-std utf8-width

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

8 releases

0.1.7 Nov 20, 2023
0.1.6 Mar 19, 2022
0.1.5 Apr 22, 2021
0.1.4 Jul 29, 2020
0.1.3 Jun 27, 2020

#141 in Encoding

Download history 128360/week @ 2024-09-17 151817/week @ 2024-09-24 154691/week @ 2024-10-01 156406/week @ 2024-10-08 163072/week @ 2024-10-15 163613/week @ 2024-10-22 175548/week @ 2024-10-29 170254/week @ 2024-11-05 166089/week @ 2024-11-12 171169/week @ 2024-11-19 161935/week @ 2024-11-26 170714/week @ 2024-12-03 174502/week @ 2024-12-10 139278/week @ 2024-12-17 94816/week @ 2024-12-24 84547/week @ 2024-12-31

521,882 downloads per month
Used in 1,070 crates (8 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


lib.rs:

UTF-8 Width

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

No runtime deps