1
0
mirror of https://github.com/anope/anope.git synced 2026-06-12 19:14:47 +02:00

Add the utf8length method to Anope::string.

This commit is contained in:
Sadie Powell
2025-09-12 14:21:39 +01:00
parent 390975e6c4
commit 679a313ae2
2 changed files with 3 additions and 3 deletions
+2
View File
@@ -14,6 +14,7 @@
#include <signal.h>
#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.
+1 -3
View File
@@ -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))