File tree Expand file tree Collapse file tree 4 files changed +57
-0
lines changed
Expand file tree Collapse file tree 4 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ exclude = []
1313
1414[dependencies ]
1515unic-ucd-version = { path = " ../version/" , version = " 0.7.0" }
16+ unic-char-property = { path = " ../../char/property/" , version = " 0.7.0" }
1617
1718[badges ]
1819maintenance = { status = " actively-developed" }
Original file line number Diff line number Diff line change 1414#![ deny( bad_style, unsafe_code, unused) ]
1515
1616extern crate unic_ucd_version;
17+ extern crate unic_char_property;
18+
19+ mod readings;
20+ pub use readings:: { definition_of, mandarin_of} ;
21+
1722use unic_ucd_version:: UnicodeVersion ;
1823
1924mod pkg_info;
Original file line number Diff line number Diff line change 1+ // Copyright 2012-2015 The Rust Project Developers.
2+ // Copyright 2017 The UNIC Project Developers.
3+ //
4+ // See the COPYRIGHT file at the top-level directory of this distribution.
5+ //
6+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9+ // option. This file may not be copied, modified, or distributed
10+ // except according to those terms.
11+
12+ pub fn definition_of ( ch : char ) -> Option < & ' static str > {
13+ data:: DEFINITIONS . find ( ch)
14+ }
15+
16+ pub fn mandarin_of ( ch : char ) -> Option < & ' static str > {
17+ // TODO: When there are two values, then the first is preferred for
18+ // zh-Hans (CN) and the second is preferred for zh-Hant (TW).
19+ data:: MANDARINS . find ( ch)
20+ }
21+
22+ mod data {
23+ use unic_char_property:: tables:: CharDataTable ;
24+ pub const DEFINITIONS : CharDataTable < & str > = include ! ( "../tables/definition_map.rsv" ) ;
25+ pub const MANDARINS : CharDataTable < & str > = include ! ( "../tables/mandarin_map.rsv" ) ;
26+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2017 The UNIC Project Developers.
2+ //
3+ // See the COPYRIGHT file at the top-level directory of this distribution.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ extern crate unic_ucd_unihan;
12+
13+ use unic_ucd_unihan:: { definition_of, mandarin_of} ;
14+
15+ #[ test]
16+ fn test_definition ( ) {
17+ assert_eq ! ( definition_of( '\u{0001}' ) , None ) ;
18+ assert_eq ! ( definition_of( '\u{340c}' ) , Some ( "a tribe of savages in South China" ) ) ;
19+ }
20+
21+ #[ test]
22+ fn test_mandarin ( ) {
23+ assert_eq ! ( mandarin_of( '\u{0001}' ) , None ) ;
24+ assert_eq ! ( mandarin_of( '\u{340c}' ) , Some ( "yí" ) ) ;
25+ }
You can’t perform that action at this time.
0 commit comments