Skip to main content

Module text

Module text 

Source
Expand description

Canonical text codecs shared across crates: shell single-quote rendering (sq_quote_buf family, byte-parity ports of upstream git’s quote.c for 2.55), percent-encoding/decoding, and small formatting helpers built on them. All crates must route quoting/percent work through this module so the codecs stay single-homed and oracle-verified.

Enums§

PercentDecodeError
Failure modes of percent_decode.
PercentEncodeMode
Safe-set mode table for percent_encode, preserving the per-site accept/reject behavior of current call sites.

Functions§

hex_byte
Append byte to out as two uppercase hex digits.
percent_decode
Strictly percent-decode value: every % must introduce a %XX escape with case-insensitive hex digits; all other bytes are copied verbatim. Returns raw bytes — callers own the UTF-8 validation and error wording.
percent_encode
Percent-encode value into out: safe bytes pass through verbatim, every other byte becomes an uppercase %XX escape.
sq_quote
Convenience wrapper around sq_quote_buf for UTF-8 arguments.
sq_quote_argv
Port of quote.c sq_quote_argv: prefix each argument with a space and render it through full sq_quote semantics.
sq_quote_argv_pretty
Space-prefixed argv rendering used by trace2 start lines (sq_quote_argv_pretty): each argument goes through sq_quote_pretty, joined by single spaces.
sq_quote_buf
Port of quote.c sq_quote_buf: always wrap in single quotes, escaping each ' or ! as '\'' / '\!'. The ! escape guards against interactive shells’ history expansion, matching upstream 2.55 (need_bs_quote).
sq_quote_buf_pretty
Port of quote.c sq_quote_buf_pretty: leave arg bare when it is non-empty and every byte is ASCII alphanumeric or one of +,-./:=@_^; otherwise fall back to sq_quote_buf semantics. An empty argument renders as ''.
sq_quote_pretty
Convenience wrapper around sq_quote_buf_pretty for UTF-8 arguments.