runestr-pancjkv

Crates.iorunestr-pancjkv
lib.rsrunestr-pancjkv
version0.1.1
sourcesrc
created_at2021-08-07 04:50:19.058483
updated_at2021-08-07 05:11:15.584645
description`rune`-based Pan-CJKV support
homepage
repository
max_upload_size
id432690
size15,858
Charles Lew (crlf0710)

documentation

https://docs.rs/runestr-pancjkv

README

rune-based PanCJKV IVD Collection support

PanCJKV IVD Collection is an unregistered IVD collection, that makes use of Unicode Variation Selectors to distinguish CJK ideograph glyphs on a per-region basis.

This crate add support for PanCJKV IVD Collection support to rune-based iterators, by allowing unannotated CJK ideograph abstract characters be transformed into annotated form explicitly.

Example

use runestr::{rune, RuneString};
use runestr_pancjkv::{PanCJKVAnnotate, PanCJKVRegion}

fn main() {
    let test = RuneString::from_str_lossy("\u{6211}\u{030C}\u{4EEC}\u{E01EE}\u{0301}");
    assert_eq!(2, test.runes().count());
    let result = test
        .runes()
        .annotate_with_pan_cjkv_region(PanCJKVRegion::XK) // annotate with a presedo region called KangXi
        .collect::<RuneString>();
    assert_eq!(
        &result.chars().collect::<Vec<_>>()[..],
        &[
            '\u{6211}',
            '\u{E01EF}', // this variation selector is inserted
            '\u{030C}',
            '\u{4EEC}',
            '\u{E01EE}', // this is untouched
            '\u{0301}'
        ]
    );
    assert_eq!(2, result.runes().count()); // rune count does not change
}

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Commit count: 0

cargo fmt