Skip to main content

os_from_bytes

Function os_from_bytes 

Source
pub fn os_from_bytes(bytes: &[u8]) -> OsString
Expand description

Build an OsString from raw filesystem-path bytes, losslessly on Unix.

  • Unix: the bytes are the OS path encoding, wrapped verbatim via OsStringExt::from_vec, so a filename whose bytes are not valid UTF-8 survives byte-for-byte.
  • Other platforms (Windows/WASI): git and jj emit their -z / machine path output as UTF-8 there, so the bytes are decoded as UTF-8. A genuinely invalid sequence — which these tools do not produce on this path — falls back to the lossy replacement, preserving the pre-existing Windows String/OsString behaviour (Unicode names like 𝓁abc still round-trip).