[core] nits

Signed-off-by: x7z4w <x7z4w@noreply.codeberg.org>
This commit is contained in:
x7z4w
2025-08-21 13:56:48 +00:00
committed by Konstantin Pastbin
parent 3f7815017e
commit 3c34765595
5 changed files with 19 additions and 11 deletions

View File

@@ -114,6 +114,20 @@ void Trim(std::string_view & sv);
void Trim(std::string_view & s, std::string_view anyOf);
void Trim(std::string & s, std::string_view anyOf);
template <std::convertible_to<std::string_view> Utf8>
size_t CountChar(Utf8 const & utf8)
{
size_t codePoints = 0;
for (auto const c : utf8)
{
if ((c & 0xC0) != 0x80)
++codePoints;
}
return codePoints;
}
bool Truncate(std::string & utf8, size_t const maxTextLengthPlus1);
// Replace the first match of the search substring in the input with the format string.