File tree Expand file tree Collapse file tree 6 files changed +34
-2
lines changed Expand file tree Collapse file tree 6 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ publish = false
8
8
build = " build.rs"
9
9
10
10
[dependencies ]
11
+ ansi_term = " 0.11.0"
11
12
base64 = " 0.9"
12
13
bitflags = " 1.0"
13
14
byteorder = " 1.0"
@@ -27,6 +28,7 @@ log = "0.4"
27
28
log4rs = " 0.8"
28
29
memmap = " 0.7"
29
30
mime = " 0.3"
31
+ nalgebra = " 0.16.12"
30
32
ndarray = " 0.12"
31
33
num = " 0.2"
32
34
num_cpus = " 1.8"
@@ -48,10 +50,9 @@ tar = "0.4.12"
48
50
tempdir = " 0.3.5"
49
51
threadpool = " 1.6"
50
52
toml = " 0.4"
53
+ unicode-segmentation = " 1.2.1"
51
54
url = " 1.6"
52
55
walkdir = " 2.0"
53
- ansi_term = " 0.11.0"
54
- nalgebra = " 0.16.12"
55
56
56
57
[target .'cfg(target_os = "linux")' .dependencies ]
57
58
syslog = " 4.0"
Original file line number Diff line number Diff line change @@ -112,6 +112,8 @@ GitHub
112
112
github
113
113
GlobError
114
114
Guybrush
115
+ graphemes
116
+ Graphemes
115
117
GzDecoder
116
118
GzEncoder
117
119
Hackerman
@@ -311,6 +313,7 @@ Tuple
311
313
typesafe
312
314
unary
313
315
unix
316
+ unicode
314
317
unwinded
315
318
UpperHex
316
319
uptime
Original file line number Diff line number Diff line change @@ -138,5 +138,7 @@ Keep lines sorted.
138
138
[ toml ] : https://docs.rs/toml/
139
139
[ url-badge ] : https://badge-cache.kominick.com/crates/v/url.svg?label=url
140
140
[ url ] : https://docs.rs/url/
141
+ [ unicode-segmentation-badge ] : https://badge-cache.kominick.com/crates/v/unicode-segmentation.svg?label=unicode-segmentation
142
+ [ unicode-segmentation ] : https://docs.rs/unicode-segmentation/
141
143
[ walkdir-badge ] : https://badge-cache.kominick.com/crates/v/walkdir.svg?label=walkdir
142
144
[ walkdir ] : https://docs.rs/walkdir/
Original file line number Diff line number Diff line change 2
2
3
3
| Recipe | Crates | Categories |
4
4
| --------| --------| ------------|
5
+ | [ Collect Unicode Graphemes] [ ex-unicode-graphemes ] | [ ![ unicode-segmentation-badge]] [ unicode-segmentation ] | [ ![ cat-encoding-badge]] [ cat-text-processing ] |
5
6
| [ Verify and extract login from an email address] [ ex-verify-extract-email ] | [ ![ regex-badge]] [ regex ] [ ![ lazy_static-badge]] [ lazy_static ] | [ ![ cat-text-processing-badge]] [ cat-text-processing ] |
6
7
| [ Extract a list of unique #Hashtags from a text] [ ex-extract-hashtags ] | [ ![ regex-badge]] [ regex ] [ ![ lazy_static-badge]] [ lazy_static ] | [ ![ cat-text-processing-badge]] [ cat-text-processing ] |
7
8
| [ Extract phone numbers from text] [ ex-phone ] | [ ![ regex-badge]] [ regex ] | [ ![ cat-text-processing-badge]] [ cat-text-processing ] |
15
16
[ ex-regex-filter-log ] : text/regex.html#filter-a-log-file-by-matching-multiple-regular-expressions
16
17
[ ex-regex-replace-named ] : text/regex.html#replace-all-occurrences-of-one-text-pattern-with-another-pattern
17
18
19
+ [ ex-unicode-graphemes ] : text/string_parsing.html#collect-unicode-graphemes
18
20
[ string_parsing-from_str ] : text/string_parsing.html#implement-the-fromstr-trait-for-a-custom-struct
19
21
20
22
{{#include links.md}}
Original file line number Diff line number Diff line change 1
1
# String Parsing
2
2
3
+ {{#include string_parsing/graphemes.md}}
4
+
3
5
{{#include string_parsing/from_str.md}}
4
6
5
7
{{#include ../links.md}}
Original file line number Diff line number Diff line change
1
+ ## Collect Unicode Graphemes
2
+
3
+ [ ![ unicode-segmentation-badge]] [ `unicode-segmentation` ] [ ![ cat-text-processing-badge]] [ cat-text-processing ]
4
+
5
+ Collect individual Unicode graphemes from UTF-8 string using the
6
+ [ ` UnicodeSegmentation::graphemes ` ] function from the [ ` unicode-segmentation ` ] crate.
7
+
8
+ ``` rust
9
+ #[macro_use]
10
+ extern crate unicode_segmentation;
11
+ use unicode_segmentation :: UnicodeSegmentation ;
12
+
13
+ fn main () {
14
+ let name = " José Guimarães\ r\ n" ;
15
+ let graphemes = UnicodeSegmentation :: graphemes (name , true )
16
+ . collect :: <Vec <& str >>();
17
+ assert_eq! (graphemes [3 ], " é" );
18
+ }
19
+ ```
20
+
21
+ [ `UnicodeSegmentation::graphemes` ] : https://docs.rs/unicode-segmentation/*/unicode_segmentation/trait.UnicodeSegmentation.html#tymethod.graphemes
22
+ [ `unicode-segmentation` ] : https://docs.rs/unicode-segmentation/1.2.1/unicode_segmentation/
You can’t perform that action at this time.
0 commit comments