From dcdc66b8f5a2e8e75d6fce2676fdd98d5af4db49 Mon Sep 17 00:00:00 2001 From: Benau Date: Fri, 25 Feb 2022 11:13:27 +0800 Subject: [PATCH] Fix undefined behavior in C++20, see #4735 --- src/utils/string_utils.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/string_utils.cpp b/src/utils/string_utils.cpp index f8f8b8bd8..e96382700 100644 --- a/src/utils/string_utils.cpp +++ b/src/utils/string_utils.cpp @@ -832,7 +832,8 @@ namespace StringUtils if (utf32[i] >= 128 || utf32[i] == '&' || utf32[i] == '<' || utf32[i] == '>' || utf32[i] == '\"' || utf32[i] == ' ') { - output << "&#x" << std::hex << std::uppercase << utf32[i] << ";"; + unsigned code = (unsigned)utf32[i]; + output << "&#x" << std::hex << std::uppercase << code << ";"; } else {