diff --git a/include/anope.h b/include/anope.h index 865727260..7e9808f55 100644 --- a/include/anope.h +++ b/include/anope.h @@ -14,6 +14,7 @@ #include #include "hashcomp.h" +#include "utfcpp/unchecked.h" namespace Anope { @@ -129,6 +130,7 @@ namespace Anope * Returns the string's length. */ inline size_type length() const { return this->_string.length(); } + inline size_type utf8length() const { return utf8::unchecked::distance(str().begin(), str().end()); } /** * Returns the size of the currently allocated storage space in the string object. diff --git a/src/command.cpp b/src/command.cpp index b1c09e9cd..475477dd6 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -17,8 +17,6 @@ #include "regchannel.h" #include "channels.h" -#include "utfcpp/unchecked.h" - void CommandReply::SendMessage(CommandSource &source, const Anope::string &msg) { SendMessage(source.service, msg); @@ -152,7 +150,7 @@ void Command::SendSyntax(CommandSource &source) { auto first = true; Anope::string prefix = Language::Translate(source.GetAccount(), _("Syntax")); - Anope::string padding(utf8::unchecked::distance(prefix.str().begin(), prefix.str().end()), ' '); + Anope::string padding(prefix.utf8length(), ' '); for (const auto &[syntax, predicate] : this->syntax) { if (predicate && !predicate(source))