#text #unicode #width

no-std unicode-width

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

7 releases

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

#5 in Text processing

Download history 49396/week @ 2018-10-14 46340/week @ 2018-10-21 51834/week @ 2018-10-28 50987/week @ 2018-11-04 53903/week @ 2018-11-11 46870/week @ 2018-11-18 52384/week @ 2018-11-25 58429/week @ 2018-12-02 59253/week @ 2018-12-09 50818/week @ 2018-12-16 39656/week @ 2018-12-23 48446/week @ 2018-12-30 53888/week @ 2019-01-06 63441/week @ 2019-01-13 62669/week @ 2019-01-20

215,362 downloads per month
Used in 3,523 crates (64 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