diff --git a/base/dll_win32.h b/base/dll_win32.h index d11fa6105..0051a8997 100644 --- a/base/dll_win32.h +++ b/base/dll_win32.h @@ -1,5 +1,5 @@ // LAF Base Library -// Copyright (c) 2020 Igara Studio S.A. +// Copyright (c) 2020-2024 Igara Studio S.A. // Copyright (c) 2016 David Capello // // This file is released under the terms of the MIT license. @@ -47,10 +47,10 @@ std::string get_dll_filename(dll lib) { std::vector buf(MAX_PATH); if (get_dll_filename_wchar(lib, buf) && - buf.size() > 1) // One char for the null char - return to_utf8(&buf[0], (int)buf.size()-1); - else - return std::string(); + buf.size() > 1) { // One char for the null char + return to_utf8(&buf[0], buf.size()-1); + } + return std::string(); } Version get_dll_version(dll lib) @@ -58,8 +58,7 @@ Version get_dll_version(dll lib) std::vector buf(MAX_PATH); if (get_dll_filename_wchar(lib, buf)) return get_file_version(&buf[0]); - else - return Version(); + return Version(); } } // namespace base diff --git a/base/string.cpp b/base/string.cpp index 3e064aaef..6942f97f7 100644 --- a/base/string.cpp +++ b/base/string.cpp @@ -1,5 +1,5 @@ // LAF Base Library -// Copyright (c) 2020-2022 Igara Studio S.A. +// Copyright (c) 2020-2024 Igara Studio S.A. // Copyright (c) 2001-2016 David Capello // // This file is released under the terms of the MIT license. @@ -71,7 +71,7 @@ std::string string_to_upper(const std::string& original) #ifdef LAF_WINDOWS -std::string to_utf8(const wchar_t* src, const int n) +std::string to_utf8(const wchar_t* src, const size_t n) { int required_size = ::WideCharToMultiByte(CP_UTF8, 0, @@ -152,13 +152,13 @@ static std::size_t insert_utf8_char(std::string* result, wchar_t chr) return size; } -std::string to_utf8(const wchar_t* src, const int n) +std::string to_utf8(const wchar_t* src, const size_t n) { // Get required size to reserve a string so string::push_back() // doesn't need to reallocate its data. std::size_t required_size = 0; const auto* p = src; - for (int i=0; i