Crate chinese_number

source ·
Expand description

Chinese Number

Convert primitive numbers to Chinese numbers, or parse Chinese numbers to primitive numbers.

This crate can convert Rust’s primitive number data types to Chinese numbers as strings. For example, 123 can be converted into 一百二十三 or 壹佰貳拾參. It supports both Traditional Chinese and Simple Chinese.

Example

extern crate chinese_number;

use chinese_number::{ChineseNumber, ChineseVariant};

assert_eq!("壹佰貳拾參", 123i8.to_uppercase_middle(ChineseVariant::Traditional));
assert_eq!("壹佰贰拾参", 123i8.to_uppercase_middle(ChineseVariant::Simple));

assert_eq!("一百二十三", 123i8.to_lowercase_middle(ChineseVariant::Traditional));

assert_eq!("十二穰三千四百五十六秭七千八百九十垓一千二百三十四京五千六百七十八兆九千零一十二億三千四百五十六萬七千八百九十", 123456789012345678901234567890i128.to_lowercase_middle(ChineseVariant::Traditional));
assert_eq!("一极二载三正四涧五沟六穰七秭八垓九京零一亿二万三千四百五十六", 1234567890123456i64.to_lowercase_low(ChineseVariant::Simple));

assert_eq!("一角二分", 0.12f64.to_lowercase_middle(ChineseVariant::Traditional));

Enums

根據 五經算術 將大的單位分為上數、中數、下數三種類型。
大寫或小寫數字。
繁體中文或簡體中文。

Traits

讓Rust程式語言的所有基本數值型別擁有中文數字的轉換能力。

Functions

將f64浮點數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。
將f64浮點數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。
將f64浮點數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。
將f64浮點數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。
將i8整數轉成中文數字。
將i8整數轉成中文數字。
將i16整數轉成中文數字。
將i16整數轉成中文數字。
將i32整數轉成中文數字。
將i32整數轉成中文數字。
將i64整數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。
將i64整數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。
將i128整數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。
將i128整數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。
將isize整數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。
將isize整數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。
將u8整數轉成中文數字。
將u8整數轉成中文數字。
將u16整數轉成中文數字。
將u16整數轉成中文數字。
將u32整數轉成中文數字。
將u32整數轉成中文數字。
將u64整數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。
將u64整數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。
將u128整數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。
將u128整數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。
將usize整數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。
將usize整數轉成中文數字。如果使用 「下數」 來作為單位標準,數值不能大於或等於10000000000000000。