diff --git a/src/marked-up_text.cpp b/src/marked-up_text.cpp index 638b2ec9dcf..eb964361c5d 100644 --- a/src/marked-up_text.cpp +++ b/src/marked-up_text.cpp @@ -139,7 +139,7 @@ std::string::const_iterator parse_markup(std::string::const_iterator i1, std::st } -// Copy string but without tags at the begining +// Copy string but without tags at the begining std::string del_tags(std::string name){ std::stringstream str; bool not_colour = true; @@ -165,7 +165,7 @@ std::string del_tags(std::string name){ if (not_name && isalpha(*it)){ not_name = false; } - + if (!not_name){ str << *it; } @@ -355,7 +355,7 @@ std::string word_wrap_text(const std::string& unwrapped_text, int font_size, int if(start_of_line) { line_width = 0; format_string = ""; - while(ch != end && *ch < (wchar_t)0x100 && is_format_char(*ch)) { + while(ch != end && *ch < (wchar_t)0x100 && is_format_char(*ch) && !ch.next_is_end()) { format_string.append(ch.substr().first, ch.substr().second); ++ch; } diff --git a/src/serialization/string_utils.cpp b/src/serialization/string_utils.cpp index dbfac9785e2..b054deca027 100644 --- a/src/serialization/string_utils.cpp +++ b/src/serialization/string_utils.cpp @@ -437,6 +437,13 @@ wchar_t utf8_iterator::operator*() const return current_char; } +bool utf8_iterator::next_is_end() +{ + if(current_substr.second == string_end) + return true; + return false; +} + const std::pair& utf8_iterator::substr() const { return current_substr; diff --git a/src/serialization/string_utils.hpp b/src/serialization/string_utils.hpp index c21cedb47f8..efc49593406 100644 --- a/src/serialization/string_utils.hpp +++ b/src/serialization/string_utils.hpp @@ -96,6 +96,7 @@ public: bool operator!=(const utf8_iterator& a) const { return ! (*this == a); } utf8_iterator& operator++(); wchar_t operator*() const; + bool next_is_end(); const std::pair& substr() const; private: void update();