Windows unicode (`_W`) api for all Win32 functions
Based on #84. The new changes
We should probably be using the unicode (
SetupDiClassGuidsFromNameW) or automatic (SetupDiClassGuidsFromName) versions of all windows functions. Otherwise devices from non-english speaking manufacturers or users in different localities may run into issues getting correct device names and information.See: https://learn.microsoft.com/en-us/windows/win32/intl/unicode-in-the-windows-api
Originally posted by @mlsvrts in https://github.com/serialport/serialport-rs/pull/84#discussion_r1148426835
In that case, I think updating these in another PR instead of putting additional changes here makes more sense to me!
Originally posted by @mlsvrts in https://github.com/serialport/serialport-rs/pull/84#discussion_r1148673211
I believe this would be a good change, since using the wide function are generally recommended and would make their usage consistent throughout the codebase. Just needs to be rebased.
I believe this would be a good change, since using the wide function are generally recommended and would make their usage consistent throughout the codebase. Just needs to be rebased.
This has been (squashed and) rebased. I lack the hardware to test this that I had last year though :/
Thank you very much for your PR @Crzyrndm and for the recent attention @RossSmyth!
I lack the hardware to test this that I had last year though :/
Did you had a piece of hardware returning actual UTF-16 codepoints?
I recommended this change since we saw issues with reporting device serial numbers as fixed by: https://github.com/serialport/serialport-rs/pull/63
It's kind of a case of "if you can do, then someone will do it."
But I doubt it would be a common issue.
If desired I can give this a more thorough review later in the week.
The API provided by the windows crate does't seem to bring more ergonomics witch respect to this buffer handling here.
If it is desired to move to the Windows crate I would recommend that windows-sys is used and not windows-rs ~~because my work computer's anti-virus kills compilation of windows-rs~~ because it is pretty big. Which I do think would be a worthwhile endeavor at some point as winapi is dead.
wrt to buffer handling, the wide literal macro could be copied for now to try and reduce allocation if that is important.
Rebased to resolve conflict with main branch.
Thank you for pushing forward with this PR @Crzyrndm! See my replies to https://github.com/serialport/serialport-rs/pull/89#pullrequestreview-2204667053. Resolved the merge conflict with main and added some more cleanup. A local test with list_ports looks good.
If desired I can give this a more thorough review later in the week.
This would be great @RossSmyth.