Commit fc3be546 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add textutil

parent 610a9ea2
Pipeline #142061 passed with stage
in 1 minute and 30 seconds
......@@ -190,6 +190,8 @@ target_sources(akregatorpart PRIVATE
crashwidget/crashwidget.cpp
utils/filtercolumnsproxymodel.cpp
utils/textutil.cpp
utils/textutil.h
command/deletesubscriptioncommand.cpp
command/createfeedcommand.cpp
......
/*
SPDX-FileCopyrightText: 2022 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "textutil.h"
// code from kitinerary/src/lib/stringutil.cpp
QChar TextUtil::normalize(QChar c)
{
// case folding
const auto n = c.toCaseFolded();
// if the character has a canonical decomposition use that and skip the
// combining diacritic markers following it
// see https://en.wikipedia.org/wiki/Unicode_equivalence
// see https://en.wikipedia.org/wiki/Combining_character
if (n.decompositionTag() == QChar::Canonical) {
return n.decomposition().at(0);
}
return n;
}
QString TextUtil::normalize(QStringView str)
{
QString out;
out.reserve(str.size());
for (const auto c : str) {
out.push_back(normalize(c));
}
return out;
}
/*
SPDX-FileCopyrightText: 2022 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QString>
namespace TextUtil
{
Q_REQUIRED_RESULT QString normalize(QStringView str);
Q_REQUIRED_RESULT QChar normalize(QChar c);
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment