melchor629 / node-flac-bindings

Nodejs bindings to libFLAC
ISC License
17 stars 1 forks source link

Fix unicode paths on windows #39

Closed melchor629 closed 2 years ago

melchor629 commented 2 years ago

When using FileDecoder and FileEncoder objects (or the almost-low-level APIs StreamDecoder and StreamEncoder with a initWithFile/initWithOggFile methods) on Windows, uses fopen to open the files. But fopen on Windows does not understand non-ascii characters in the path.

The PR uses custom open mechanism for the low level API, in which in Windows converts the UTF-8 string into UTF-16 to use _wfopen_s to open the file (the Wide String version of fopen_s) which supports paths with Unicode characters.

This PR does not fix for other APIs like in Metadata due to limitations in the FLAC C API.

Fixes #37

coveralls commented 2 years ago

Coverage Status

Coverage increased (+2.7%) to 91.389% when pulling e9af6a48185dac4741c5437b06d982020d36c8e6 on fix/37-unicode-paths-on-windows into 8d2b913150193f6c04e357cfdc313dde3a1bad33 on master.