kelp

Crates.iokelp
lib.rskelp
version0.6.0
sourcesrc
created_at2017-07-23 23:10:47.774456
updated_at2024-11-17 12:33:23.936262
descriptionA convert tool for Japanese.
homepage
repositoryhttps://github.com/panther-king/kelp
max_upload_size
id24747
size1,018,540
panther-king (panther-king)

documentation

https://panther-king.github.io/kelp/kelp/

README

kelp

CI Crates.io Crates.io license

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

cargo add kelp
[dependencies]
kelp = "0.6"

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アイウ
}
Commit count: 72

cargo fmt