File tree Expand file tree Collapse file tree 3 files changed +47
-1
lines changed Expand file tree Collapse file tree 3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ extern crate unic_char_property;
1919mod readings;
2020pub use readings:: { definition_of, mandarin_of} ;
2121
22+ mod variants;
23+ pub use variants:: { simplified_variant_of, traditional_variant_of} ;
24+
2225use unic_ucd_version:: UnicodeVersion ;
2326
2427mod 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 simplified_variant_of ( ch : char ) -> Option < char > {
13+ data:: SIMPLIFIED_VARIANT . find ( ch)
14+ }
15+
16+ pub fn traditional_variant_of ( ch : char ) -> Option < char > {
17+ data:: TRADITIONAL_VARIANT . find ( ch)
18+ }
19+
20+ mod data {
21+ use unic_char_property:: tables:: CharDataTable ;
22+ pub const SIMPLIFIED_VARIANT : CharDataTable < char > =
23+ include ! ( "../tables/simplified_variant_map.rsv" ) ;
24+ pub const TRADITIONAL_VARIANT : CharDataTable < char > =
25+ include ! ( "../tables/traditional_variant_map.rsv" ) ;
26+ }
Original file line number Diff line number Diff line change 1010
1111extern crate unic_ucd_unihan;
1212
13- use unic_ucd_unihan:: { definition_of, mandarin_of} ;
13+ use unic_ucd_unihan:: {
14+ definition_of,
15+ mandarin_of,
16+ simplified_variant_of,
17+ traditional_variant_of,
18+ } ;
1419
1520#[ test]
1621fn test_definition ( ) {
@@ -23,3 +28,15 @@ fn test_mandarin() {
2328 assert_eq ! ( mandarin_of( '\u{0001}' ) , None ) ;
2429 assert_eq ! ( mandarin_of( '\u{340c}' ) , Some ( "yí" ) ) ;
2530}
31+
32+ #[ test]
33+ fn test_simplified_variant ( ) {
34+ assert_eq ! ( simplified_variant_of( '\u{0001}' ) , None ) ;
35+ assert_eq ! ( simplified_variant_of( '\u{380f}' ) , Some ( '\u{37c6}' ) ) ;
36+ }
37+
38+ #[ test]
39+ fn test_traditional_variant ( ) {
40+ assert_eq ! ( traditional_variant_of( '\u{0001}' ) , None ) ;
41+ assert_eq ! ( traditional_variant_of( '\u{37c6}' ) , Some ( '\u{380f}' ) ) ;
42+ }
You can’t perform that action at this time.
0 commit comments