Skip to main content

japanese_codepoints/
lib.rs

1//! # japanese-codepoints
2//!
3//! A Rust library for validating and working with Japanese character code
4//! points based on JIS standards.
5//!
6//! ## Character sets
7//!
8//! | Feature | Module | Description |
9//! |---|---|---|
10//! | *(default)* | — | ASCII control / printable via [`CodePoints`] |
11//! | `codepoints-jisx0201` | [`jisx0201`] | Latin letters and halfwidth katakana |
12//! | `codepoints-jisx0208` | [`jisx0208`] | Hiragana, katakana, Latin, Greek, Cyrillic, symbols |
13//! | `codepoints-jisx0208kanji` | [`jisx0208kanji`] | 6 355 kanji (JIS X 0208 Level 1 & 2) |
14//! | `codepoints-jisx0213kanji` | [`jisx0213kanji`] | 10 050 kanji (JIS X 0213 Level 1–4) |
15//! | `full` | — | All of the above |
16//!
17//! ## Quick start
18//!
19//! ```rust
20//! use japanese_codepoints::CodePoints;
21//!
22//! let allowed = CodePoints::new(vec![0x3041, 0x3042]); // ぁ, あ
23//! assert!(allowed.contains("あ"));
24//! assert!(!allowed.contains("う"));
25//! ```
26//!
27//! ## Multi-set validation
28//!
29//! Use [`contains_all_in_any`] to check whether every character in a string
30//! belongs to at least one of several character sets:
31//!
32//! ```rust
33//! use japanese_codepoints::{CodePoints, contains_all_in_any};
34//!
35//! let hiragana = CodePoints::new(vec![0x3042, 0x3044]); // あ, い
36//! let katakana = CodePoints::new(vec![0x30A2, 0x30A4]); // ア, イ
37//! assert!(contains_all_in_any("あア", &[&hiragana, &katakana]));
38//! ```
39//!
40//! For a version that returns a structured error, see
41//! [`validation::validate_all_in_any`].
42
43pub mod codepoints;
44pub mod data;
45pub mod validation;
46
47#[cfg(feature = "codepoints-jisx0201")]
48pub mod jisx0201;
49
50#[cfg(feature = "codepoints-jisx0208")]
51pub mod jisx0208;
52
53#[cfg(feature = "codepoints-jisx0208kanji")]
54pub mod jisx0208kanji;
55
56#[cfg(feature = "codepoints-jisx0213kanji")]
57pub mod jisx0213kanji;
58
59// ── re-exports ────────────────────────────────────────────────────────────────
60
61pub use codepoints::{contains_all_in_any, CodePoints};
62pub use validation::ValidationError;
63
64#[cfg(feature = "codepoints-jisx0201")]
65pub use jisx0201::{JisX0201, Katakana as JisX0201Katakana, LatinLetters as JisX0201LatinLetters};
66
67#[cfg(feature = "codepoints-jisx0208")]
68pub use jisx0208::{
69    BoxDrawingChars, CyrillicLetters, GreekLetters, Hiragana, JisX0208, Katakana, LatinLetters,
70    SpecialChars,
71};
72
73#[cfg(feature = "codepoints-jisx0208kanji")]
74pub use jisx0208kanji::JisX0208Kanji;
75
76#[cfg(feature = "codepoints-jisx0213kanji")]
77pub use jisx0213kanji::JisX0213Kanji;