There are tons of crates to help with dealing with the horrors of UTF-16 strings on Windows, but if you just want a quick and dirty helper, here's one generated by ChatGPT that looks similar to code I've seen a couple of times: