Expand description
Self-contained Wubi 86 codec — pure algorithm + types, zero external imports.
This module is intentionally usable from build.rs (via #[path]) as
well as the runtime crate. Do not add use crate::... lines here, or
extern crate alloc;; the only allowed imports are core::*.
Everything is #[inline] and zero-allocation. The encoder writes into a
caller-provided [u8; 4] buffer and returns the populated length.
Structs§
- Decomp
Ref - Borrowed character decomposition. Cheap to construct from
&[char]/&[Stroke], suitable for both stack-only build pipelines and the runtime hot path.
Enums§
- Encode
Error - Why an
encode_with_lookupcall failed. Always recoverable — never panics. - Shape
- Wubi 字形 (character shape) — three-way classification used by the 末笔 识别码 rule. Discriminants 1..=3 match the seed-file numbering.
- Stroke
- One of the five Wubi stroke categories. Discriminants 1..=5 match the canonical numbering used in seed data files; do not renumber.
Constants§
- DAN_
BI_ HUA - 5 单笔画 字根 — encode as
letter letter L L. - JIANMING_
ZIGEN - 25 键名字根 of Wubi 86 — encode as letter × 4.
Functions§
- encode_
with_ lookup - Encode a decomposition using the supplied 字根 lookup. Writes the code
bytes into
outand returns the number of bytes written (3 or 4). - region_
letter - Region letter — first key of each stroke region. Used by 成字字根 rule.
- shibie_
ma - Wubi 86 末笔识别码: (last stroke, shape) → key letter.