#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

#12 in Text processing

Download history 40345/week @ 2018-12-20 43700/week @ 2018-12-27 56654/week @ 2019-01-03 58188/week @ 2019-01-10 64424/week @ 2019-01-17 58980/week @ 2019-01-24 61223/week @ 2019-01-31 66029/week @ 2019-02-07 64570/week @ 2019-02-14 67131/week @ 2019-02-21 70393/week @ 2019-02-28 70446/week @ 2019-03-07 69720/week @ 2019-03-14 63808/week @ 2019-03-21 69614/week @ 2019-03-28

215,362 downloads per month
Used in 4,000 crates (70 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