(arg: &OsStr)
| 291 | /// Preserve the exact platform units of a non-UTF-8 argv entry. |
| 292 | #[cfg(unix)] |
| 293 | fn encode_invalid_units(arg: &OsStr) -> Option<String> { |
| 294 | use std::fmt::Write as _; |
| 295 | use std::os::unix::ffi::OsStrExt as _; |
| 296 | |
| 297 | if arg.to_str().is_some() { |
| 298 | return None; |
| 299 | } |
| 300 | let mut encoded = String::from("unix-hex:"); |
| 301 | for byte in arg.as_bytes() { |
| 302 | let _ = write!(encoded, "{byte:02x}"); |
| 303 | } |
| 304 | Some(encoded) |
| 305 | } |
| 306 | |
| 307 | #[cfg(windows)] |
| 308 | fn encode_invalid_units(arg: &OsStr) -> Option<String> { |