Skip to content

Commit

Permalink
Unicode paths on windows correctly handled
Browse files Browse the repository at this point in the history
for mp3, sf2, scm and scp

Closes #1301
  • Loading branch information
baconpaul committed Sep 30, 2024
1 parent d7fce38 commit fd58c8b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libs/sst/libgig-modified
Submodule libgig-modified updated 1 files
+47 −36 src/RIFF.cpp
Binary file added resources/test_samples/聲音不好.flac
Binary file not shown.
Binary file added resources/test_samples/聲音不好.mp3
Binary file not shown.
12 changes: 12 additions & 0 deletions src/sample/loaders/load_mp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,23 @@ bool Sample::parseMP3(const fs::path &p)
{
mp3dec_t mp3d;
mp3dec_file_info_t info;
#if WIN32
int count =
MultiByteToWideChar(CP_UTF8, 0, p.u8string().c_str(), p.u8string().length(), NULL, 0);
std::wstring wstr(count, 0);
MultiByteToWideChar(CP_UTF8, 0, p.u8string().c_str(), p.u8string().length(), &wstr[0], count);
if (mp3dec_load_w(&mp3d, &wstr[0], &info, nullptr, nullptr))
{
SCLOG("Failed to parse MP3");
return false;
}
#else
if (mp3dec_load(&mp3d, p.u8string().c_str(), &info, nullptr, nullptr))
{
SCLOG("Failed to parse MP3");
return false;
}
#endif

if (info.channels < 1 || info.channels > 2)
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/sample/sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ bool Sample::loadFromSF2(const fs::path &p, sf2::File *f, int sampleIndex)

auto s = sfsample;

auto fnp = fs::path{f->GetRiffFile()->GetFileName()};
auto fnp = fs::path(fs::u8path(f->GetRiffFile()->GetFileName()));
displayName = fmt::format("{} - ({} @ {})", s->Name, fnp.filename().u8string(), sampleIndex);

if (frameSize == 2 && channels == 1 && sfsample->SampleType == sf2::Sample::MONO_SAMPLE)
Expand Down

0 comments on commit fd58c8b

Please sign in to comment.