Skip to main content

trim_ows

Function trim_ows 

Source
pub fn trim_ows(s: &[u8]) -> &[u8] ⓘ
Expand description

s without leading and trailing SP and HTAB.

<[u8]>::trim_ascii is deliberately not used: it also strips vertical tab and form feed, which are invalid in a field value and must be refused, not silently removed. NBSP and every other byte stay too.

§Examples

use parse_net::text::trim_ows;

assert_eq!(trim_ows(b" \t a b \t"), b"a b");
assert_eq!(trim_ows(b"\x0ba\x0c"), b"\x0ba\x0c");
assert_eq!(trim_ows(b"   "), b"");