News for hackers. Stuff that matters.
Re:String Lengths in Unicode by account42 on Monday September 09, 2019 @09:37AM (#20918000)
> Creating a non-UTF8 rust string is UB.

So how does rust deal with filenames under Linux? Use somethinge other than strings?

Re:String Lengths in Unicode by loonyphoenix on Monday September 09, 2019 @10:33AM (#20918536)
Yep. Rust has a PathBuf[1] type for dealing with paths in a platform-native manner. You can convert it to a Rust string type, but it's a conversion that can fail[2] or may be lossy[3].

[1] https://doc.rust-lang.org/std/path/struct.PathBuf.html

[2] https://doc.rust-lang.org/std/path/struct.PathBuf.html#metho...

[3] https://doc.rust-lang.org/std/path/struct.PathBuf.html#metho...

Re:String Lengths in Unicode by TheCoelacanth on Monday September 09, 2019 @10:38AM (#20918582)
Yes, this is what OsStr/OsString[1] are for.

[1] https://doc.rust-lang.org/std/ffi/struct.OsString.html

Re:String Lengths in Unicode by masklinn on Monday September 09, 2019 @10:28AM (#20918501)
Yes: https://doc.rust-lang.org/std/ffi/struct.OsString.html

This is also used to deal with filenames on Windows, as they're a different flavour of "not unicode", IIRC that's the original use case for WTF8.

It also has a separate pseudo-string type to deal with C strings: https://doc.rust-lang.org/std/ffi/struct.CString.html