#text #unicode #width

no-std unicode-width

Determine displayed width of char and str types according to Unicode Standard Annex #11 rules

6 releases

0.1.4 Dec 23, 2016
0.1.3 Aug 20, 2015
0.1.2 Jul 9, 2015
0.1.1 Apr 19, 2015
0.0.1 Apr 14, 2015

#7 in Text processing

Download history 40132/week @ 2018-09-18 43686/week @ 2018-09-25 43171/week @ 2018-10-02 44036/week @ 2018-10-09 48659/week @ 2018-10-16 44833/week @ 2018-10-23 50632/week @ 2018-10-30 50761/week @ 2018-11-06 52988/week @ 2018-11-13 51084/week @ 2018-11-20 48705/week @ 2018-11-27 54968/week @ 2018-12-04 55180/week @ 2018-12-11

105,953 downloads per month
Used in 3,121 crates (55 directly)

MIT/Apache

45KB
662 lines

unicode-width

Determine displayed width of char and str types according to Unicode Standard Annex #11 rules.

Build Status

Documentation

extern crate unicode_width;

use unicode_width::UnicodeWidthStr;

fn main() {
    let teststr = "Hello, world!";
    let width = UnicodeWidthStr::width(teststr);
    println!("{}", teststr);
    println!("The above string is {} columns wide.", width);
    let width = teststr.width_cjk();
    println!("The above string is {} columns wide (CJK).", width);
}

features

unicode-width does not depend on libstd, so it can be used in crates with the #![no_std] attribute.

crates.io

You can use this package in your project by adding the following to your Cargo.toml:

[dependencies]
unicode-width = "0.1.5"

No runtime deps