I have started using some ffi on windows to see how it all works. It was all going reasonably well, until I wanted to construct a string to send to the the OS. In this case below, a string is being assigned to a windows structure, that will later be passed into a windows function call:
let class_name_os = OsStr::new(class_name).encode_wide().chain(Some(0)
wc.lpszClassName = class_name_os;
I found the conversion “incantation” above on the Web after trying to work out the correct way myself, with no obvous anwser. I note that is quite long and tedious for what it does. class_name_os is a windows style utf16 zero terminated string. I was hoping, and expected a single function to do the same work but cannot seem to find one.
Is there another way to do this? If not, is there a proposal to make this a bit more utilitarian, if not is there a rationale I can read about why not.