unic_ucd_normal/
composition.rs

1// Copyright 2015 The Servo 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
12use unic_char_property::tables::CharDataTable;
13
14pub mod data {
15    use crate::decomposition_type::long_names::*;
16    use crate::DecompositionType;
17    use unic_char_property::tables::CharDataTable;
18
19    pub const CANONICAL_COMPOSITION_MAPPING: CharDataTable<CharDataTable<char>> =
20        include!("../tables/canonical_composition_mapping.rsv");
21
22    pub const CANONICAL_DECOMPOSITION_MAPPING: CharDataTable<&[char]> =
23        include!("../tables/canonical_decomposition_mapping.rsv");
24
25    #[cfg_attr(rustfmt, rustfmt_skip)]
26    pub const COMPATIBILITY_DECOMPOSITION_MAPPING: CharDataTable<(DecompositionType, &[char])> =
27        include!("../tables/compatibility_decomposition_mapping.rsv");
28}
29
30/// Canonical Composition of the character.
31pub fn canonical_composition(c: char) -> Option<CharDataTable<char>> {
32    data::CANONICAL_COMPOSITION_MAPPING.find(c)
33}
34
35/// Canonical Decomposition of the character.
36pub fn canonical_decomposition(c: char) -> Option<&'static [char]> {
37    data::CANONICAL_DECOMPOSITION_MAPPING.find(c)
38}
39
40/// Compatibility Decomposition of the character.
41pub fn compatibility_decomposition(c: char) -> Option<&'static [char]> {
42    data::COMPATIBILITY_DECOMPOSITION_MAPPING
43        .find(c)
44        .map(|it| it.1)
45}