Crate wana_kana

source ·
Expand description

ワナカナ <–> WanaKana <–> わなかな

Utility library for checking and converting between Japanese characters - Hiragana, Katakana - and Romaji (Ported from https://github.com/WaniKani/WanaKana)

Conversions

We provide the ConvertJapanese Trait, which is implemented for &str, that allows the same conversions as mentioned above, by calling the corresponding method directly on the &str.

use wana_kana::ConvertJapanese;
// to kana
assert_eq!("o".to_kana(), "お");
assert_eq!("ona".to_kana(), "おな");
assert_eq!("onaji".to_kana(), "おなじ");
assert_eq!("onaji BUTTSUUJI".to_kana(), "おなじ ブッツウジ");
assert_eq!("ONAJI buttsuuji".to_kana(), "オナジ ぶっつうじ");
assert_eq!("座禅‘zazen’スタイル".to_kana(), "座禅「ざぜん」スタイル");
// to hiragana
assert_eq!("toukyou,オオサカ".to_hiragana(), "とうきょう、おおさか");
// to katakana
assert_eq!("toukyou,おおさか".to_katakana(), "トウキョウ、オオサカ");
// to romaji
assert_eq!("ひらがな カタカナ".to_romaji(), "hiragana katakana");

Checks

To check whether a string is Japanese, romaji, kana, etc check the IsJapaneseStr trait. There are also functions to check a single char in the is IsJapaneseChar trait.

use wana_kana::IsJapaneseStr;
assert_eq!("げーむ".is_hiragana(), true);
assert_eq!("ア".is_kana(), true);
assert_eq!("Tōkyō and Ōsaka".is_romaji(), true);
assert_eq!("切腹".is_kanji(), true);
assert_eq!("Aあア".is_mixed(), true);
assert_eq!("勢い".contains_kanji(), true);

Tokenize

tokenize Splits input into array of strings separated by opinionated TokenType.

Re-exports

pub use traits::ConvertJapanese;
pub use traits::IsJapaneseChar;
pub use traits::IsJapaneseStr;

Modules

tokenizetokenize
Splits input into array of strings separated by opinionated TokenType.
The wana_kana::ConvertJapanese trait is implemented for &str, which allows conversion between kana and romaji.
Strips trailing Okurigana if input is a mix of Kanji and Kana

Macros

Structs

Options to set.