pub fn escapeshellarg(arg: &[u8]) -> Result<Vec<u8>, Error>Expand description
PHP escapeshellarg($arg) on Unix: the argument between single quotes,
each ' written as '\'', so a POSIX shell reads it back as one word.
Bytes are read as multibyte characters of the locale PHP runs in
(C.UTF-8, PHP’s default since 8.0): a valid UTF-8 character is copied
whole, and a byte that does not start one is dropped (mblen() fails on
it). A NUL byte raises ValueError, as in PHP.
use php_std::string::escapeshellarg;
assert_eq!(escapeshellarg(b"it's").unwrap(), b"'it'\\''s'");
assert_eq!(escapeshellarg(b"caf\xc3\xa9\xff").unwrap(), "'caf\u{e9}'".as_bytes());
assert_eq!(escapeshellarg(b"a\0b").unwrap_err().php_class(), "ValueError");