4 releases (breaking)
0.4.0 | Jan 18, 2023 |
---|---|
0.3.0 | Jan 13, 2020 |
0.2.0 | Jan 5, 2020 |
0.1.0 | Jul 23, 2017 |
#476 in Text processing
45 downloads per month
605KB
791 lines
kelp
Convert tool for Japanese.
This is a porting from jaconv(python) written in Rust.
About
- Convert characters between full-width and half-width
- From full-width to half-width
- From half-width to full-width
- Convert characters between hiragana and katakana
- From hiragana to katakana
- From katakana to hiragana
Usage
Add kelp
as a dependency in your Cargo.toml
[dependencies]
kelp = "0.4"
Quick Example
First, you should build ConvOption
.
ConvOption
has flags of conversion method.
After building ConvOption
, you can convert characters with functions
of kelp
.
extern crate kelp;
use kelp::*;
use kelp::conv_option::ConvOption;
fn main() {
// All flags are disabled in default
let option = ConvOption::build()
.enable_ascii() // Convert ascii
.enable_digit() // Convert digit
.enable_kana() // Convert kana
.finalize(); // Returns ConvOption with specified flags
// From hiragana to katakana(full-width)
println!("{}", hira2kata("あいうえお", option)); // アイウエオ
// From hiragana to katakana(half-width)
println!("{}", hira2hkata("あいうえお", option)); // アイウエオ
// From katakana(full-width) to hiragana
println!("{}", kata2hira("アイウエオ", option)); // あいうえお
// From half-width to full-width
println!("{}", h2z("abc123アイウ", option)); // ABC123アイウ
// From full-width to half-width
println!("{}", z2h("ABC123アイウ", option)); // ABC123アイウ
}
Dependencies
~2MB
~29K SLoC