{"id":30028049,"url":"https://github.com/amorphobia/chinese-numerals","last_synced_at":"2025-08-06T14:14:03.389Z","repository":{"id":57550590,"uuid":"463485133","full_name":"amorphobia/chinese-numerals","owner":"amorphobia","description":"Convert numbers to Chinese numerals","archived":false,"fork":false,"pushed_at":"2022-03-21T12:11:04.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-02T00:35:33.345Z","etag":null,"topics":["chinese-numerals"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/chinese-numerals","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amorphobia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-25T10:08:58.000Z","updated_at":"2022-03-17T06:49:09.000Z","dependencies_parsed_at":"2022-09-01T05:21:49.346Z","dependency_job_id":null,"html_url":"https://github.com/amorphobia/chinese-numerals","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/amorphobia/chinese-numerals","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amorphobia%2Fchinese-numerals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amorphobia%2Fchinese-numerals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amorphobia%2Fchinese-numerals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amorphobia%2Fchinese-numerals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amorphobia","download_url":"https://codeload.github.com/amorphobia/chinese-numerals/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amorphobia%2Fchinese-numerals/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269093181,"owners_count":24358617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-06T02:00:09.910Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chinese-numerals"],"created_at":"2025-08-06T14:13:59.533Z","updated_at":"2025-08-06T14:14:03.380Z","avatar_url":"https://github.com/amorphobia.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chinese Numerals\n\nConverts primitive integers and [big integers](https://docs.rs/num-bigint) to [Chinese numerals](https://en.wikipedia.org/wiki/Chinese_numerals).\n\nAccording to 《[五经算术](https://zh.wikipedia.org/wiki/%E4%BA%94%E7%B6%93%E7%AE%97%E8%A1%93)》, for representing numbers larger than 1,0000, there have been ten names (亿, 兆, 京, 垓, 秭, 壤, 沟, 涧, 正, and 载) and three systems (下数 short scale, 中数 mid-scale, 上数 long scale). Plus the myriad scale, in which each name represents a number 1,0000 times the previous, this crate can convert integers to four scales.\n\n## Usage\n\nAdd to `Cargo.toml`:\n```toml\n[dependencies]\nchinese-numerals = \"0.2\"\n```\n\nAll structs have implemented [`Display`](https://doc.rust-lang.org/std/fmt/trait.Display.html) trait's normal (with `\"{}\"`) and alternative (with `\"{:#}\"`) formats, converting to lowercase and uppercase Chinese numbers. Besides, [`ChineseNumeral`](https://docs.rs/chinese-numerals/latest/chinese_numerals/trait.ChineseNumeral.html) trait provides following functions:\n\n- [`to_lowercase`](https://docs.rs/chinese-numerals/latest/chinese_numerals/trait.ChineseNumeral.html#method.to_lowercase)\n- [`to_lowercase_simp`](https://docs.rs/chinese-numerals/latest/chinese_numerals/trait.ChineseNumeral.html#method.to_lowercase#method.to_lowercase_simp)\n- [`to_lowercase_trad`](https://docs.rs/chinese-numerals/latest/chinese_numerals/trait.ChineseNumeral.html#method.to_lowercase#method.to_lowercase_trad)\n- [`to_uppercase`](https://docs.rs/chinese-numerals/latest/chinese_numerals/trait.ChineseNumeral.html#method.to_lowercase#method.to_uppercase)\n- [`to_uppercase_simp`](https://docs.rs/chinese-numerals/latest/chinese_numerals/trait.ChineseNumeral.html#method.to_lowercase#method.to_uppercase_simp)\n- [`to_uppercase_trad`](https://docs.rs/chinese-numerals/latest/chinese_numerals/trait.ChineseNumeral.html#method.to_lowercase#method.to_uppercase_trad)\n\n## Premitive Integers\n\nFor each scale, a struct has been implemented to perform the convertion.\n\n[`ShortScaleInt`](https://docs.rs/chinese-numerals/latest/chinese_numerals/struct.ShortScaleInt.html) has implemented [`From`](https://doc.rust-lang.org/core/convert/trait.From.html) trait for `i8`, `u8`, `i16`, `u16`, `i32`, and `u32`, and [`TryFrom`](https://doc.rust-lang.org/core/convert/trait.TryFrom.html) trait for `i64`, `u64`, `i128`, `u128`, `isize`, and `usize`.\n\n[`MyriadScaleInt`](https://docs.rs/chinese-numerals/latest/chinese_numerals/struct.MyriadScaleInt.html), [`MidScaleInt`](https://docs.rs/chinese-numerals/latest/chinese_numerals/struct.MidScaleInt.html), and [`LongScaleInt`](https://docs.rs/chinese-numerals/latest/chinese_numerals/struct.LongScaleInt.html) have implemented `From` trait for all premitive integers.\n\n### Examples\n```\nuse chinese_numerals::{ChineseNumeral, ShortScaleInt, MidScaleInt};\n\nlet num = ShortScaleInt::from(1_0203_0405);\nassert_eq!(\"一垓零二兆零三万零四百零五\", format!(\"{}\", num));\nassert_eq!(\"壹垓零贰兆零叁万零肆佰零伍\", format!(\"{:#}\", num));\n\nlet num = MidScaleInt::from(1_0203_0405);\nassert_eq!(\"一億零二百零三萬零四百零五\", num.to_lowercase_trad());\nassert_eq!(\"壹億零貳佰零叄萬零肆佰零伍\", num.to_uppercase_trad());\n```\n\n## Big Integers\n\nFor scales except short scale, a struct has been implemented to perform the convertion from [`BigInt`](https://docs.rs/num-bigint/latest/num_bigint/struct.BigInt.html) and [`BigUint`](https://docs.rs/num-bigint/latest/num_bigint/struct.BigUint.html).\n\n[`MyriadScaleBigInt`](https://docs.rs/chinese-numerals/latest/chinese_numerals/struct.MyriadScaleBigInt.html), [`MidScaleBigInt`](https://docs.rs/chinese-numerals/latest/chinese_numerals/struct.MidScaleBigInt.html), and [`LongScaleBigInt`](https://docs.rs/chinese-numerals/latest/chinese_numerals/struct.LongScaleBigInt.html) have implemented `TryFrom` trait for both `BigInt` and `BigUint`.\n\n### Dependencies\n\nTo enable `bigint` feature, set dependencies in `Cargo.toml`:\n```toml\n[dependencies]\nnum-bigint = \"0.4\"\nchinese-numerals = { version = \"0.2\", features = [\"bigint\"] }\n```\n\n### Examples\n```\nuse chinese_numerals::{ChineseNumeral, LongScaleBigInt};\nuse num_bigint::BigUint;\n\n// 130_5480_5271_5637_0597_2964\nlet num = BigUint::new(vec![463665380, 3016835882, 707]);\nlet num = LongScaleBigInt::try_from(num).expect(\"Out of range\");\n\nassert_eq!(\n    \"一百三十万五千四百八十兆五千二百七十一万\\\n    五千六百三十七亿零五百九十七万二千九百六十四\",\n    num.to_lowercase_simp()\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famorphobia%2Fchinese-numerals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famorphobia%2Fchinese-numerals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famorphobia%2Fchinese-numerals/lists"}