-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaces the command line interface from ANSI to UNICODE on Windows. #1411
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, one comment below. @pedrolcl You also committed encoding related changes in the past, would you like to have a look at this as well?
include/fluidsynth/misc.h
Outdated
@@ -67,6 +67,7 @@ extern "C" { | |||
|
|||
FLUIDSYNTH_API int fluid_is_soundfont(const char *filename); | |||
FLUIDSYNTH_API int fluid_is_midifile(const char *filename); | |||
FLUIDSYNTH_API void* fluid_alloc(size_t len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitant to make fluid_alloc public for everyone. It is only used inside libfluidsynth. I'd prefer that you use plain malloc()
and free()
in fluidsynth.c
and do not make it public.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, and thank you for checking.
I'll replace the code with malloc and free, test it, and then make a pull request again.
Please wait a while.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completed.
https://github.com/stardusteyes/fluidsynth/pull/1/files
Please confirm.
Quality Gate passedIssues Measures |
@derselbst : This is just another method of fixing the same problems that were already reported in #128 #983 #1322 #1388 and then supposedly fixed by #718 #1325 and #1390. If the reported problems were already fixed, I don't see the need to re-fix it again. But this is more a comment for the issue report instead of the pull request. About the PR itself: it is quite intrusive: +99 −87! and I agree with your comment about The core of this method is |
dev->sndfile = sf_open(filename, SFM_WRITE, &info); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in http://libsndfile.github.io/libsndfile/api.html#open :
The sf_open() function opens the sound file at the specified path. The filename is byte encoded, but may be utf-8 on Linux, while on Mac OS X it will use the filesystem character set. On Windows, there is also a Windows specific sf_wchar_open() that takes a UTF16_BE encoded filename.
It is quite absurd that libsndfile
does not allow UTF-8 file names in Windows like it does on Linux. It may be acceptable this workaround in Fluidsynth, but this should be fixed upstream (libsndfile
) as well.
Even more funny: in 1.1.0 you may find this change:
Use UTF-8 as internal path encoding on Windows platform.
This is an internal change to unify and simplify the handling of file paths.
On the Windows platform, the file path is always converted to UTF-8 and converted to UTF-16 only for calls to WinAPI functions.
The behavior of the functions for opening files on other platforms does notchange.
I'm closing this pull request due to the comment that the code is not good. |
This pull request replaces the command line interface from ANSI to UNICODE on Windows.
Closes #1410
All additional changes are between #ifdef _WIN32 and #endif.
So this only affects Windows-specific code, especially code that relies on command line strings.
include/fluidsynth/misc.h :
Added export of fluid_alloc().
This fix is for use the macro FLUID_ARRAY.
Without this fix, when linking import library for the libfluidsynth, an error would occur that the symbol "fluid_alloc" is not found.
src/bindings/fluid_filerenderer.c :
sf_open() cannot be used, because it converts the filename to an ANSI string.
This is because sf_open() does support pipes, but not sf_wchar_open().
src/fluidsynth.c :
This procedure is inspired by FFmpeg code.
https://github.com/FFmpeg/FFmpeg/blob/8d940a07d19023a98689f353e4425a14688547e9/fftools/cmdutils.c#L171C1-L223C2
The new utf-8 arguments are created on the heap, and released at the end of main().
This is because, there is a possibility that delete_fluid_settings() will be called without calling new_fluid_settings().
The operation of these codes was tested using binaries built with Microsoft Visual studio and MSYS2.
Calls from Win32API, and Windows command prompt were confirmed to work as expected.
It has not been confirmed whether the codes will operate normally in other build and execution environments.
Tested with non-ANSI characters.
for example:
In this case, an error will occur when running with Fluidsynth 2.3.7.
And the file names are not displayed correctly.
The code in the pull request fixes these issues.