From 0a71af9d6a6644749b5f23a0c1d59936a46c6169 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sat, 28 Nov 2020 23:31:51 +0100 Subject: [PATCH] util/library: Fix unicode support Related: #359 --- source/util/util-library.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source/util/util-library.cpp b/source/util/util-library.cpp index 8fd8bed5..4741002e 100644 --- a/source/util/util-library.cpp +++ b/source/util/util-library.cpp @@ -54,7 +54,7 @@ util::library::library(std::filesystem::path file) : _library(nullptr) throw std::runtime_error("Failed to load library."); } #elif defined(ST_UNIX) - _library = dlopen(file.string().c_str(), RTLD_LAZY); + _library = dlopen(file.u8string().c_str(), RTLD_LAZY); if (!_library) { if (char* error = dlerror(); error) throw std::runtime_error(error); @@ -86,9 +86,7 @@ static std::unordered_map> libraries std::shared_ptr<::util::library> util::library::load(std::filesystem::path file) { - std::string utf8_name = file.string(); - - auto kv = libraries.find(utf8_name); + auto kv = libraries.find(file.u8string()); if (kv != libraries.end()) { if (auto ptr = kv->second.lock(); ptr) return ptr; @@ -96,12 +94,12 @@ std::shared_ptr<::util::library> util::library::load(std::filesystem::path file) } auto ptr = std::make_shared<::util::library>(file); - libraries.emplace(utf8_name, ptr); + libraries.emplace(file.u8string(), ptr); return ptr; } std::shared_ptr<::util::library> util::library::load(std::string_view name) { - return load(std::filesystem::path(name)); + return load(std::filesystem::u8path(name)); }