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:
@@ -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
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user