Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
patches/ | 03-May-2024 | - | 14 | 11 | ||
scripts/ | 03-May-2024 | - | 322 | 250 | ||
src/ | 03-May-2024 | - | 597 | 440 | ||
.cargo_vcs_info.json | D | 03-May-2024 | 74 | 6 | 5 | |
.gitignore | D | 03-May-2024 | 30 | 4 | 3 | |
.travis.yml | D | 03-May-2024 | 1.1 KiB | 29 | 26 | |
Android.bp | D | 03-May-2024 | 2.1 KiB | 74 | 67 | |
COPYRIGHT | D | 03-May-2024 | 321 | 8 | 7 | |
Cargo.toml | D | 03-May-2024 | 1.4 KiB | 44 | 39 | |
Cargo.toml.orig | D | 03-May-2024 | 905 | 30 | 24 | |
LICENSE | D | 03-May-2024 | 10.6 KiB | 202 | 169 | |
LICENSE-APACHE | D | 03-May-2024 | 10.6 KiB | 202 | 169 | |
LICENSE-MIT | D | 03-May-2024 | 1 KiB | 26 | 22 | |
METADATA | D | 03-May-2024 | 457 | 20 | 19 | |
MODULE_LICENSE_APACHE2 | D | 03-May-2024 | 0 | |||
NOTICE | D | 03-May-2024 | 10.6 KiB | 202 | 169 | |
OWNERS | D | 03-May-2024 | 40 | 2 | 1 | |
README.md | D | 03-May-2024 | 1.6 KiB | 59 | 42 | |
TEST_MAPPING | D | 03-May-2024 | 208 | 12 | 11 |
README.md
1# unicode-width 2 3Determine displayed width of `char` and `str` types according to 4[Unicode Standard Annex #11][UAX11] rules. 5 6[UAX11]: http://www.unicode.org/reports/tr11/ 7 8[](https://travis-ci.org/unicode-rs/unicode-width) 9 10[Documentation](https://unicode-rs.github.io/unicode-width/unicode_width/index.html) 11 12```rust 13extern crate unicode_width; 14 15use unicode_width::UnicodeWidthStr; 16 17fn main() { 18 let teststr = "Hello, world!"; 19 let width = UnicodeWidthStr::width(teststr); 20 println!("{}", teststr); 21 println!("The above string is {} columns wide.", width); 22 let width = teststr.width_cjk(); 23 println!("The above string is {} columns wide (CJK).", width); 24} 25``` 26 27**NOTE:** The computed width values may not match the actual rendered column 28width. For example, the woman scientist emoji comprises of a woman emoji, a 29zero-width joiner and a microscope emoji. 30 31```rust 32extern crate unicode_width; 33use unicode_width::UnicodeWidthStr; 34 35fn main() { 36 assert_eq!(UnicodeWidthStr::width("��"), 2); // Woman 37 assert_eq!(UnicodeWidthStr::width("��"), 2); // Microscope 38 assert_eq!(UnicodeWidthStr::width("����"), 4); // Woman scientist 39} 40``` 41 42See [Unicode Standard Annex #11][UAX11] for precise details on what is and isn't 43covered by this crate. 44 45## features 46 47unicode-width does not depend on libstd, so it can be used in crates 48with the `#![no_std]` attribute. 49 50## crates.io 51 52You can use this package in your project by adding the following 53to your `Cargo.toml`: 54 55```toml 56[dependencies] 57unicode-width = "0.1.7" 58``` 59