P
P
Pavel2422019-02-06 12:44:31
Qt
Pavel242, 2019-02-06 12:44:31

How to replace decimal xml entities with hexadecimal ones?

To generate XML, I use the QXmlStreamReader class, in the final document the entities are decimal, that is, & #13; instead of & #xD; Is there any way to deal with this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ighor July, 2019-12-27
@IGHOR

void translateInt10ToHex(QString& str)
{
    static const QRegExp rX("(\\&\\#[0-9]{2,3})");
    int pos = 0;

    while ((pos = rX.indexIn(str, pos)) > -1)
    {
        QString xB = rX.cap(1);
        str.replace(pos++, xB.size(), QLatin1String("&#x") + QByteArray(1, xB.right(xB.size() - 2).toUShort()).toHex().toUpper());
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question