mirror of
https://github.com/openharmony/third_party_rust_unicode-normalization.git
synced 2026-07-19 15:03:34 -04:00
e4fd0e1b21f39e7d8ff35da53eb11d0624bbf6cc
Fix #11. The algorithm for composition of Hangul Jamo is: - L (choseong jamo) + V (jungseong jamo) = LV (syllable block) - LV (syllable block) + T (jongseong jamo) = LVT (syllable block) However, the LV and LVT syllable blocks are intermingled in the unicode block. In particular, for each pair LV, you will first see the syllable block LV, followed by syllable blocks for LVT for each T. The LV+T composition was a simple addition of offsets. Our algorithm did not ignore the LVT syllable blocks, which meant that LVT+T would just offset further and produce an unrelated syllable block. By ensuring that the `S_index` is a multiple of `T_count`, we filter for only LV syllable blocks (which occur every `T_count` codepoints in the S block)
Unicode character composition and decomposition utilities as described in Unicode Standard Annex #15.
extern crate unicode_normalization;
use unicode_normalization::char::compose;
use unicode_normalization::UnicodeNormalization;
fn main() {
assert_eq!(compose('A','\u{30a}'), Some('Å'));
let s = "ÅΩ";
let c = s.nfc().collect::<String>();
assert_eq!(c, "ÅΩ");
}
crates.io
You can use this package in your project by adding the following
to your Cargo.toml:
[dependencies]
unicode-normalization = "0.1.1"
Description
Languages
Rust
96.5%
Python
3.5%