• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Iterators which split strings on Grapheme Cluster or Word boundaries, according
2to the [Unicode Standard Annex #29](http://www.unicode.org/reports/tr29/) rules.
3
4[![Build Status](https://travis-ci.org/unicode-rs/unicode-segmentation.svg)](https://travis-ci.org/unicode-rs/unicode-segmentation)
5
6[Documentation](https://unicode-rs.github.io/unicode-segmentation/unicode_segmentation/index.html)
7
8```rust
9use unicode_segmentation::UnicodeSegmentation;
10
11fn main() {
12    let s = "a̐éö̲\r\n";
13    let g = s.graphemes(true).collect::<Vec<&str>>();
14    let b: &[_] = &["a̐", "é", "ö̲", "\r\n"];
15    assert_eq!(g, b);
16
17    let s = "The quick (\"brown\") fox can't jump 32.3 feet, right?";
18    let w = s.unicode_words().collect::<Vec<&str>>();
19    let b: &[_] = &["The", "quick", "brown", "fox", "can't", "jump", "32.3", "feet", "right"];
20    assert_eq!(w, b);
21
22    let s = "The quick (\"brown\")  fox";
23    let w = s.split_word_bounds().collect::<Vec<&str>>();
24    let b: &[_] = &["The", " ", "quick", " ", "(", "\"", "brown", "\"", ")", " ", " ", "fox"];
25    assert_eq!(w, b);
26}
27```
28
29# no_std
30
31unicode-segmentation does not depend on libstd, so it can be used in crates
32with the `#![no_std]` attribute.
33
34# crates.io
35
36You can use this package in your project by adding the following
37to your `Cargo.toml`:
38
39```toml
40[dependencies]
41unicode-segmentation = "1.7.1"
42```
43
44# Change Log
45
46## 1.7.1
47
48* Update docs on version number
49
50## 1.7.0
51
52* [#87](https://github.com/unicode-rs/unicode-segmentation/pull/87) Upgrade to Unicode 13
53* [#79](https://github.com/unicode-rs/unicode-segmentation/pull/79) Implement a special-case lookup for ascii grapheme categories
54* [#77](https://github.com/unicode-rs/unicode-segmentation/pull/77) Optimization for grapheme iteration
55
56## 1.6.0
57
58* [#72](https://github.com/unicode-rs/unicode-segmentation/pull/72) Upgrade to Unicode 12
59
60## 1.5.0
61
62* [#68](https://github.com/unicode-rs/unicode-segmentation/pull/68) Upgrade to Unicode 11
63
64## 1.4.0
65
66* [#56](https://github.com/unicode-rs/unicode-segmentation/pull/56) Upgrade to Unicode 10
67
68## 1.3.0
69
70* [#24](https://github.com/unicode-rs/unicode-segmentation/pull/24) Add support for sentence boundaries
71* [#44](https://github.com/unicode-rs/unicode-segmentation/pull/44) Treat `gc=No` as a subset of `gc=N`
72
73## 1.2.1
74
75* [#37](https://github.com/unicode-rs/unicode-segmentation/pull/37):
76  Fix panic in `provide_context`.
77* [#40](https://github.com/unicode-rs/unicode-segmentation/pull/40):
78  Fix crash in `prev_boundary`.
79
80## 1.2.0
81
82* New `GraphemeCursor` API allows random access and bidirectional iteration.
83* Fixed incorrect splitting of certain emoji modifier sequences.
84
85## 1.1.0
86
87* Add `as_str` methods to the iterator types.
88
89## 1.0.3
90
91* Code cleanup and additional tests.
92
93## 1.0.1
94
95* Fix a bug affecting some grapheme clusters containing Prepend characters.
96
97## 1.0.0
98
99* Upgrade to Unicode 9.0.0.
100