taglib-rust icon indicating copy to clipboard operation
taglib-rust copied to clipboard

Fix Unicode paths on Windows (& accept more paths on Unix)

Open yourname3 opened this issue 2 months ago • 0 comments

Hello,

I have run into #11 on my Windows machine. I believe this is because passing UTF-8 to the system file APIs simply does not actually work for Windows, and so calling taglib_file_new and taglib_file_new_type fails as well.

Instead, this pull request makes it so on Windows, the Paths are encoded in UTF-16/WTF-16, and passed through taglib_file_new_wchar and taglib_file_new_type_wchar (two bindings that only exist on Windows).

I also tweaked the Unix code for taglib_file_new and taglib_file_new_type to avoid the intermediate conversion to UTF-8, as other paths than pure UTF-8 should be valid on Unix platforms as well.

Finally, I change the API for File::new_type to take a P: AsRef<Path> argument for its filename, rather than just an &str (to make the code more consistent). This should probably be considered a breaking change; perhaps I should have bumped the semver.

Depending on if/when this is able to be merged, if anyone else just needs a quick fix for Unicode on Windows, you can patch in my fork:

[patch.crates-io]
taglib = { git = "https://github.com/yourname3/taglib-rust.git" }

yourname3 avatar Nov 06 '25 17:11 yourname3