diff --git a/src/bindings/fluid_filerenderer.c b/src/bindings/fluid_filerenderer.c index 401daadb4..d17373996 100644 --- a/src/bindings/fluid_filerenderer.c +++ b/src/bindings/fluid_filerenderer.c @@ -288,9 +288,43 @@ new_fluid_file_renderer(fluid_synth_t *synth) FLUID_LOG(FLUID_ERR, "Invalid or unsupported audio file format settings"); goto error_recovery; } - + +#ifdef _WIN32 + if (0 == FLUID_STRCMP("-", filename)) + { + dev->sndfile = sf_open(filename, SFM_WRITE, &info); + } + else + { + int u16_count; + LPWSTR wc_filename; + dev->sndfile = NULL; + + // utf-8 filename to utf-16 wc_filename + if (1 > (u16_count = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filename, -1, NULL, 0))) + { + FLUID_LOG(FLUID_ERR, "Failed to convert UTF8 string to wide char string"); + } + else if (NULL == (wc_filename = (LPWSTR)FLUID_ARRAY(WCHAR, u16_count))) + { + FLUID_LOG(FLUID_ERR, "Out of memory"); + } + else + { + if (u16_count != MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filename, -1, wc_filename, u16_count)) + { + FLUID_LOG(FLUID_ERR, "Failed to convert UTF8 string to wide char string"); + } + else + { + dev->sndfile = sf_wchar_open(wc_filename, SFM_WRITE, &info); + } + FLUID_FREE(wc_filename); + } + } +#else dev->sndfile = sf_open(filename, SFM_WRITE, &info); - +#endif if(!dev->sndfile) { FLUID_LOG(FLUID_ERR, "Failed to open audio file '%s' for writing", filename); diff --git a/test/test_fast_render.c b/test/test_fast_render.c index c6b0ecaca..9772f12f0 100644 --- a/test/test_fast_render.c +++ b/test/test_fast_render.c @@ -51,12 +51,10 @@ int main(void) delete_fluid_synth(synth); delete_fluid_settings(settings); -#if 0 FILE *file; file = FLUID_FOPEN(TEST_WAV_UTF8, "rb"); TEST_ASSERT(file != NULL); TEST_ASSERT(FLUID_FCLOSE(file) == 0); -#endif return EXIT_SUCCESS; }