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");
To check whether a string is Japanese, romaji, kana, etc, use the is_*
functions
in is_*
modules, or equivalently use the IsJapaneseStr
trait.
There are also functions to check a single char
available in the utils
module,
and the corresponding trait is IsJapaneseChar
. Refer to the links for detailed
information.
Re-exports
Modules
Test if all chars of
input
are HiraganaTest if all chars of
input
are KatakanaConvert input to Hiragana
Convert input to Katakana
Convert kana to romaji
Splits input into array of strings separated by opinionated token types