Skip to main content

Module codec

Module codec 

Source
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§

DecompRef
Borrowed character decomposition. Cheap to construct from &[char] / &[Stroke], suitable for both stack-only build pipelines and the runtime hot path.

Enums§

EncodeError
Why an encode_with_lookup call 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 out and 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.