I need a few examples of non-utf8 OsString/PathBuf for my unit tests

I am writing a program that behaves differently depends on whether the input string is valid UTF-8. I can test the "valid UTF-8" but can't do the "invalid UTF-8" branch for obvious reason.

I tried to googled them, but the results are not helpful at all.

Yeah, that's tricky, because there's no cross-platform way to create a non-utf8 OsString, every unhappy string is unhappy in its own way.

See how this case is tested in Cargo: Don't panic when printing JSON with non-utf8 paths by matklad · Pull Request #9226 · rust-lang/cargo · GitHub