From b93b362e2f7ae01347aa4e8b4536814cf570e21b Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 26 Jan 2017 19:39:36 +0000 Subject: [PATCH] Fix wide-string support for wav-file reader. --- simgear/sound/readwav.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/simgear/sound/readwav.cxx b/simgear/sound/readwav.cxx index 16df381f..59746dba 100644 --- a/simgear/sound/readwav.cxx +++ b/simgear/sound/readwav.cxx @@ -380,17 +380,22 @@ ALvoid* loadWAVFromFile(const SGPath& path, unsigned int& format, ALsizei& size, if (!path.exists()) { throw sg_io_exception("loadWAVFromFile: file not found", path); } - + Buffer b; b.path = path; - + gzFile fd; - std::string ps = path.local8BitStr(); +#if defined(SG_WINDOWS) + std::wstring ws = path.wstr(); + fd = gzopen_w(ws.c_str(), "rb"); +#else + std::string ps = path.utf8Str(); fd = gzopen(ps.c_str(), "rb"); +#endif if (!fd) { throw sg_io_exception("loadWAVFromFile: unable to open file", path); } - + try { loadWavFile(fd, &b); } catch (sg_exception& e) {