Skip to main content

cjk_convert_rs/
lib.rs

1//! CJK character conversion: Simplified/Traditional Chinese and Japanese Kanji.
2//!
3//! This is a Rust port of the npm package [`cjk-conv`](https://www.npmjs.com/package/cjk-conv).
4//! Other crates can depend on it with:
5//!
6//! ```toml
7//! cjk-convert-rs = { git = "https://github.com/flier268/cjk-convert-rs" }
8//! # or a path / crates.io dependency
9//! ```
10//!
11//! ```
12//! use cjk_convert_rs::{cn2tw, tw2cn};
13//! assert_eq!(cn2tw("简繁转换功能测试"), "簡繁轉換功能測試");
14//! assert_eq!(tw2cn("簡繁轉換功能測試"), "简繁转换功能测试");
15//! ```
16
17mod cjk;
18mod map;
19mod options;
20pub mod strtable;
21pub mod util;
22
23#[cfg(feature = "jp")]
24pub mod jp;
25#[cfg(feature = "novel")]
26pub mod novel;
27#[cfg(feature = "table")]
28pub mod table;
29#[cfg(feature = "zh")]
30pub mod zh;
31
32pub use options::ConvertOptions;
33
34/// Crate version (npm `cjk-conv/version`).
35pub const VERSION: &str = env!("CARGO_PKG_VERSION");
36
37#[cfg(feature = "zh")]
38pub use zh::{
39    cn2tw, cn2tw_min, cn2tw_min_with, cn2tw_raw, cn2tw_with, convert_with_table, table_cn2tw,
40    table_cn2tw_min, table_cn2tw_plus, table_tw2cn, table_tw2cn_min, table_tw2cn_plus, tw2cn,
41    tw2cn_min, tw2cn_min_with, tw2cn_raw, tw2cn_with, wiki_s2t, wiki_s2t_v2, wiki_t2s, wiki_t2s_v2,
42    SAFE_MODE_CHAR, SAFE_MODE_CHAR_MIN,
43};
44
45#[cfg(feature = "jp")]
46pub use jp::{cjk2jp, cjk2zhs, cjk2zht, jp2zhs, jp2zht, zh2jp};
47
48pub use cjk::is_cjk;