OsStr

:= [
    Utf8(Str),
    UnixBytes(List(U8)),
    WindowsU16s(List(U16)),
]

Represent operating-system strings without losing non-Unicode data.

Values that are valid Unicode use one canonical UTF-8 representation. Native Unix bytes and Windows UTF-16 units that cannot be represented as Unicode still roundtrip exactly through host effects; use display only when a lossy representation is acceptable.

from_str : Str -> OsStr

Create an OS string from UTF-8 text. The host lowers this text to the active OS representation.

utf8 : Str -> OsStr

Create a UTF-8 text OS string.

unix : Str -> OsStr

Create a Unix-compatible OS string from Unicode text.

unix_bytes : List(U8) -> OsStr

Create a Unix OS string from raw bytes. Valid UTF-8 is canonicalized; otherwise the bytes are preserved exactly.

windows : Str -> OsStr

Create a Windows-compatible OS string from Unicode text.

windows_u16s : List(U16) -> OsStr

Create a Windows OS string from raw UTF-16 units. Valid Unicode is canonicalized; otherwise the units are preserved exactly.

from_quote : Str -> Try(OsStr, [BadQuotedBytes(Str)])

Build an OS string from a quoted string literal.

to_str_try : OsStr -> Try(Str, [InvalidStr(U64)])

Convert an OS string to a string if its raw representation is valid text.

display : OsStr -> Str

Convert an OS string to a best-effort display string, replacing invalid text with U+FFFD. This representation is lossy and must not be used for roundtripping.

to_inspect : OsStr -> Str

Customize debug output for Str.inspect.

is_eq : OsStr, OsStr -> Bool

Compare OS strings by their exact tagged representation.

to_raw : OsStr -> Raw

Expose the host ABI representation.

from_raw : Raw -> OsStr

Build an OS string from the host ABI representation.

Raw : [Utf8(Str), UnixBytes(List(U8)), WindowsU16s(List(U16))]

The structural representation used only at native host boundaries. OsStr remains the single public operating-system string abstraction.