From 22d685eca387e79e0b27ddd22e923df70e337052 Mon Sep 17 00:00:00 2001 From: Kindi Date: Sat, 4 May 2024 19:56:30 +0800 Subject: [PATCH] ensure fitness --- CHANGELOG.md | 1 + components/lua/utf8.cpp | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a0fcf8d0b..69fe34eaca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -246,6 +246,7 @@ Task #5896: Do not use deprecated MyGUI properties Task #6085: Replace boost::filesystem with std::filesystem Task #6149: Dehardcode Lua API_REVISION + Task #6505: UTF-8 support in Lua scripts Task #6624: Drop support for saves made prior to 0.45 Task #7048: Get rid of std::bind Task #7113: Move from std::atoi to std::from_char diff --git a/components/lua/utf8.cpp b/components/lua/utf8.cpp index 2a585dac2d..7bc8d345a7 100644 --- a/components/lua/utf8.cpp +++ b/components/lua/utf8.cpp @@ -96,7 +96,7 @@ namespace LuaUtf8 utf8["char"] = [](const sol::variadic_args args) -> std::string { std::string result{}; - std::wstring_convert> converter; + std::wstring_convert, char32_t> converter; for (size_t i = 0; i < args.size(); ++i) { int64_t codepoint = getInteger(args[i], (i + 1), "char"); @@ -104,8 +104,7 @@ namespace LuaUtf8 throw std::runtime_error( "bad argument #" + std::to_string(i + 1) + " to 'char' (value out of range)"); - // this feels dodgy if wchar_t is 16-bit as MAXUTF won't fit in sixteen bits - result += converter.to_bytes(static_cast(codepoint)); + result += converter.to_bytes(static_cast(codepoint)); } return result; };