mongol_convert/lib.rs
1#![forbid(unsafe_code)]
2// TODO(remove before binding stage): silence dead_code while the spine is wired up incrementally.
3// Every item is exercised by unit tests; once the router/translators consume them this comes off.
4#![allow(dead_code)]
5//! # mongol-convert
6//!
7//! Pure-Rust core of the Mongolian Encoding Converter (`mongol-convert`), ported from the
8//! original Java library `com.zvvnmod.mongolconvert`.
9//!
10//! Design & decisions: `docs/superpowers/specs/2026-06-18-meco-rust-port-design.md`.
11//!
12//! Ground rules baked into this crate:
13//! - Generated Java tables are the historical behavior baseline; Rust-owned Zvvnmod rules may
14//! intentionally override them when the project adopts corrected semantics.
15//! - Conversions route through the intermediate **Zvvnmod** encoding.
16//! - The build has no I/O or framework and is pure compute on every platform, including
17//! `wasm32-unknown-unknown`. UTN #57 target conversion is linked in through the pure-Rust
18//! `zvvnmod-utn57` crate; no external command or interpreter is started.
19//!
20//! Status: scaffolding — the shared spine (encoding types, errors, string helpers) is in place.
21//! Translation routing and the shape/letter subsystems are added in later steps.
22
23mod code_mapper;
24mod code_type;
25mod dispatch;
26mod error;
27mod letter;
28mod repair;
29mod router;
30mod shape;
31mod strings;
32mod tables;
33mod unicode;
34mod utn57_shape;
35mod word;
36
37pub use code_type::{CodeSeries, CodeType};
38pub use error::MongolConvertError;
39pub use router::{
40 translate, translate_with_options, translate_with_warnings, Translation, TranslationOptions,
41 Warning,
42};
43
44/// Restore legacy SoftBank/iOS emoji that collide with MenkShape PUA.
45///
46/// This is a normalization helper for paste paths. It does not decode MenkShape; it only maps
47/// modern Unicode emoji back to the corresponding MenkShape private-use code points when that
48/// collision is known.
49pub fn restore_menk_shape_emoji(input: &str) -> String {
50 shape::softbank_emoji::restore_menk_shape(input).into_owned()
51}
52
53/// Crate version (currently just the Cargo package version). A table-provenance tag
54/// (the Java commit the generated tables come from) will be appended once tables exist.
55pub fn version() -> &'static str {
56 env!("CARGO_PKG_VERSION")
57}