From 6b3b717cf5de78f2632fa5973b91398cef7894fe Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Thu, 19 Mar 2020 18:25:41 +0100 Subject: [PATCH] Fixed sound for non ascii systems --- modules/renderer/audio/sounds.ts | 2 +- native/serverconnection/src/audio/file/wav.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/renderer/audio/sounds.ts b/modules/renderer/audio/sounds.ts index 994a7f8..c32a1e1 100644 --- a/modules/renderer/audio/sounds.ts +++ b/modules/renderer/audio/sounds.ts @@ -8,7 +8,7 @@ import * as paths from "path"; namespace audio.sounds { export async function play_sound(file: sound.SoundFile) : Promise { await new Promise((resolve, reject) => { - let pathname = paths.dirname(location.pathname); + let pathname = paths.dirname(decodeURIComponent(location.pathname)); if(pathname[0] === '/' && pathname[2] === ':') //e.g.: /C:/test... pathname = pathname.substr(1); const path = paths.join(pathname, file.path); diff --git a/native/serverconnection/src/audio/file/wav.cpp b/native/serverconnection/src/audio/file/wav.cpp index 4db294c..a5dd482 100644 --- a/native/serverconnection/src/audio/file/wav.cpp +++ b/native/serverconnection/src/audio/file/wav.cpp @@ -4,6 +4,7 @@ #include "./wav.h" #include "../../logger.h" +#include using namespace tc::audio::file; @@ -37,7 +38,8 @@ WAVReader::~WAVReader() { } FileOpenResult WAVReader::open_file(std::string& error) { - this->is_.open(this->file_path_, std::ifstream::in | std::ifstream::binary); + //C:\Users\%D0%9E%D0%BB%D0%B5%D0%B3\AppData\Roaming\TeaClient\tmp\ui\release_1584625323\index.html + this->is_.open(std::filesystem::u8path(this->file_path_), std::ifstream::in | std::ifstream::binary); if(!this->is_) { error = tr("failed to open file"); return FileOpenResult::OPEN_RESULT_ERROR;