Struct icu_normalizer::properties::CanonicalComposition
source · pub struct CanonicalComposition { /* private fields */ }
Expand description
The raw canonical composition operation.
Callers should generally use ComposingNormalizer
instead of this API.
However, this API is provided for callers such as HarfBuzz that specifically
want access to the raw canonical composition operation e.g. for use in a
glyph-availability-guided custom normalizer.
Implementations§
source§impl CanonicalComposition
impl CanonicalComposition
sourcepub fn compose(&self, starter: char, second: char) -> Option<char>
pub fn compose(&self, starter: char, second: char) -> Option<char>
Performs canonical composition (including Hangul) on a pair of
characters or returns None
if these characters don’t compose.
Composition exclusions are taken into account.
Examples
let comp = icu_normalizer::properties::CanonicalComposition::new();
assert_eq!(comp.compose('a', 'b'), None); // Just two non-composing starters
assert_eq!(comp.compose('a', '\u{0308}'), Some('ä'));
assert_eq!(comp.compose('ẹ', '\u{0302}'), Some('ệ'));
assert_eq!(comp.compose('𝅗', '𝅥'), None); // Composition exclusion
assert_eq!(comp.compose('ে', 'া'), Some('ো')); // Second is starter
assert_eq!(comp.compose('ᄀ', 'ᅡ'), Some('가')); // Hangul LV
assert_eq!(comp.compose('가', 'ᆨ'), Some('각')); // Hangul LVT
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a new CanonicalComposition
using compiled data.
✨ Enabled with the compiled_data
Cargo feature.
sourcepub fn try_new_with_any_provider(
provider: &(impl AnyProvider + ?Sized)
) -> Result<Self, NormalizerError>
pub fn try_new_with_any_provider( provider: &(impl AnyProvider + ?Sized) ) -> Result<Self, NormalizerError>
A version of Self::new
that uses custom data provided by an AnyProvider
.
sourcepub fn try_new_with_buffer_provider(
provider: &(impl BufferProvider + ?Sized)
) -> Result<Self, NormalizerError>
pub fn try_new_with_buffer_provider( provider: &(impl BufferProvider + ?Sized) ) -> Result<Self, NormalizerError>
A version of Self::new
that uses custom data provided by a BufferProvider
.
✨ Enabled with the serde
feature.
sourcepub fn try_new_unstable<D>(provider: &D) -> Result<Self, NormalizerError>
pub fn try_new_unstable<D>(provider: &D) -> Result<Self, NormalizerError>
A version of Self::new
that uses custom data provided by a DataProvider
.