#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 30238/week @ 2018-05-27 36205/week @ 2018-06-03 35590/week @ 2018-06-10 30244/week @ 2018-06-17 34051/week @ 2018-06-24 34000/week @ 2018-07-01 35417/week @ 2018-07-08 39379/week @ 2018-07-15 40692/week @ 2018-07-22 36801/week @ 2018-07-29 40205/week @ 2018-08-05 39763/week @ 2018-08-12 35322/week @ 2018-08-19

105,953 downloads per month
Used in 2,813 crates (51 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