Bug 1797755 - Part 5: Use a single initial mark stack size regardless of whether...
[gecko.git] / third_party / rust / unicode-width / README.md
blob595e16380ba8d21121a557139a5f88d11cd9dc87
1 # unicode-width
3 Determine displayed width of `char` and `str` types according to
4 [Unicode Standard Annex #11][UAX11] rules.
6 [UAX11]: http://www.unicode.org/reports/tr11/
8 [![Build Status](https://travis-ci.org/unicode-rs/unicode-width.svg)](https://travis-ci.org/unicode-rs/unicode-width)
10 [Documentation](https://unicode-rs.github.io/unicode-width/unicode_width/index.html)
12 ```rust
13 extern crate unicode_width;
15 use unicode_width::UnicodeWidthStr;
17 fn 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);
25 ```
27 **NOTE:** The computed width values may not match the actual rendered column
28 width. For example, the woman scientist emoji comprises of a woman emoji, a
29 zero-width joiner and a microscope emoji.
31 ```rust
32 extern crate unicode_width;
33 use unicode_width::UnicodeWidthStr;
35 fn main() {
36     assert_eq!(UnicodeWidthStr::width("👩"), 2); // Woman
37     assert_eq!(UnicodeWidthStr::width("🔬"), 2); // Microscope
38     assert_eq!(UnicodeWidthStr::width("👩‍🔬"), 4); // Woman scientist
40 ```
42 See [Unicode Standard Annex #11][UAX11] for precise details on what is and isn't
43 covered by this crate.
45 ## features
47 unicode-width does not depend on libstd, so it can be used in crates
48 with the `#![no_std]` attribute.
50 ## crates.io
52 You can use this package in your project by adding the following
53 to your `Cargo.toml`:
55 ```toml
56 [dependencies]
57 unicode-width = "0.1.7"
58 ```