From ba9f4e93c2db803f0019daea1d676dfeb0a76274 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 12 Sep 2025 14:21:53 +0100 Subject: [PATCH] Redo how information tables are built to be multibyte aware. --- src/misc.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/misc.cpp b/src/misc.cpp index 6980ded20..444e6ed1d 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -222,23 +222,21 @@ InfoFormatter::InfoFormatter(NickCore *acc) : nc(acc) void InfoFormatter::Process(std::vector &buffer) { buffer.clear(); - for (const auto &[key, value] : this->replies) { - Anope::string s; - for (unsigned i = key.length(); i < this->longest; ++i) - s += " "; - s += key + ": " + Language::Translate(this->nc, value.c_str()); - - buffer.push_back(s); + auto line = key; + line += ": "; + line += Anope::string(longest - key.utf8length(), ' '); + line += Language::Translate(this->nc, value.c_str()); + buffer.push_back(line); } } Anope::string &InfoFormatter::operator[](const Anope::string &key) { Anope::string tkey = Language::Translate(this->nc, key.c_str()); - if (tkey.length() > this->longest) - this->longest = tkey.length(); + if (tkey.utf8length() > this->longest) + this->longest = tkey.utf8length(); this->replies.emplace_back(tkey, ""); return this->replies.back().second; }