Skip to main content

ecstrcode

Function ecstrcode 

Source
pub fn ecstrcode(s: &str) -> u32
Expand description

Direct port of ecstrcode(char *s) at Src/parse.c:426. Encode a string into a single wordcode (short strings ≤4 bytes packed inline; longer strings get an offset into the deduped registry).

The long-string path stores the METAFIED bytes (matches what C’s strs region contains): collapse Rust UTF-8 chars in 0x80..=0xff to single bytes, then apply zsh metafy (high bytes ≥ 0x83 → Meta=0x83 + byte^0x20). Length tracking (ECSOFFS) uses the metafied byte count — same as C strlen(s) + 1 where C’s s is already metafied at this point.