QtCraft API C++ classes QML types Handbook

QcNameText Namespace

Names people type and others read (player names, preset names; decision E-232): limits count Unicode code points, not UTF-16 units, and cuts fall between graphemes, so an emoji or a letter with its accents is kept whole or dropped whole and no lone surrogate is left behind. More...

Header: #include <common/core/QcNameText.h>

Functions

QString clean(const QString &text, qsizetype maxCodePoints)
qsizetype codePoints(QStringView text)
QString fit(const QString &text, qsizetype maxCodePoints)

Detailed Description

Function Documentation

QString QcNameText::clean(const QString &text, qsizetype maxCodePoints)

Returns text without unpaired surrogates, non-characters, control and format characters, trimmed, then fitted to maxCodePoints (and trimmed again).

qsizetype QcNameText::codePoints(QStringView text)

Returns the code points of text; an unpaired surrogate counts as one.

QString QcNameText::fit(const QString &text, qsizetype maxCodePoints)

Returns the longest start of text that ends on a grapheme boundary and has at most maxCodePoints code points. Nothing else is changed (no trimming, no filtering).