hangeul

Korean alphabet manipulation library


Keywords
libhangul, hangeul, korean, hangul
License
MIT

Documentation

hangeul-rs

Build Status docs badge crates version badge

A lightweight Korean alphabet manipulation library for Rust. No external crates are used.

Only modern, composable Korean unicode blocks are supported (AC00–D7AF, 1100–11FF, 3130–318F).

[dependencies]
hangeul = "0.4.0"

Usage

extern crate hangeul;

fn main() {
    // literally: pikachu transliterated
    let subject = "ν”ΌμΉ΄μΈ„";

    // Korean marks the topic of the sentence with a post position
    // particle: 이 follows consonants, and κ°€ follows vowels.
    let post_position = match hangeul::ends_in_consonant(subject).unwrap() {
        true => "이",
        false => "κ°€"
    };

    // -> A wild pikachu has appeared!
    let sentence = format!("μ•Όμƒμ˜ {}{} λ‚˜νƒ€λ‚¬λ‹€!", subject, post_position);
    println!("{}", sentence); // μ•Όμƒμ˜ ν”ΌμΉ΄μΈ„κ°€ λ‚˜νƒ€λ‚¬λ‹€!

    // get_lead is an alias of get_choseong, to get the first character
    // of a Hangeul syllable.
    let sentence_in_choseong = sentence.chars()
                                .map(|c| hangeul::get_lead(&c).unwrap_or(c))
                                .collect::<String>();

    println!("{}", sentence_in_choseong); // γ…‡γ……γ…‡ γ…γ…‹γ…Šγ„± γ„΄γ…Œγ„΄γ„·!
}

Examples

Examples.

Documentation

Docs.rs

License

Distributed under MIT License