Crates.io | kelp |
lib.rs | kelp |
version | 0.5.0 |
source | src |
created_at | 2017-07-23 23:10:47.774456 |
updated_at | 2024-03-16 08:07:23.314373 |
description | A convert tool for Japanese. |
homepage | |
repository | https://github.com/panther-king/kelp |
max_upload_size | |
id | 24747 |
size | 1,018,345 |
Convert tool for Japanese.
This is a porting from jaconv(python) written in Rust.
Add kelp
as a dependency in your Cargo.toml
cargo add kelp
[dependencies]
kelp = "0.5"
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アイウ
}