diff --git a/src/common/str_utils.cpp b/src/common/str_utils.cpp index b80f2788ec..6970f198c4 100644 --- a/src/common/str_utils.cpp +++ b/src/common/str_utils.cpp @@ -261,6 +261,22 @@ void StringBuilder::append_string(const char *str) { *current_pos_ = '\0'; } +void StringBuilder::append_string_view(string_view_utf8 str) { + + while (true) { + if (is_problem()) { + return; + } + + char b = str.getbyte(); + if (b == '\0') { + return; + } + + append_char(b); + } +} + void StringBuilder::append_printf(const char *fmt, ...) { va_list args; va_start(args, fmt); diff --git a/src/common/str_utils.hpp b/src/common/str_utils.hpp index aa981061cb..c308ed81ed 100644 --- a/src/common/str_utils.hpp +++ b/src/common/str_utils.hpp @@ -6,6 +6,7 @@ #include #include #include +#include "../lang/string_view_utf8.hpp" inline constexpr char CHAR_SPACE = ' '; inline constexpr char CHAR_NBSP = '\xA0'; /// Non Breaking Space @@ -384,6 +385,8 @@ class StringBuilder { void append_string(const char *str); + void append_string_view(string_view_utf8 str); + /// Appends text to the builder, using vsnprintf under the hood. void append_printf(const char *fmt, ...); diff --git a/src/gui/MItem_menus.cpp b/src/gui/MItem_menus.cpp index c0928a2bdf..4551801ed1 100644 --- a/src/gui/MItem_menus.cpp +++ b/src/gui/MItem_menus.cpp @@ -1,5 +1,6 @@ #include "MItem_menus.hpp" #include "ScreenHandler.hpp" +#include "str_utils.hpp" #include