Qt中有哪些工具可以解码HTML4实体?

Qt中有哪些工具可以解码HTML4实体?,qt,Qt,我有一个具有HTML4实体的输入QString,如õ。但我在Qt中找不到任何这样做的设施。在Qt中有这样做的方法吗?如果可能,我希望避免使用QTextDocument,这样就不必引入QtGui 此链接中列出了HTML 4实体: 出于好奇,我四处看了看 我找到了这个。但是,它使用OP想要阻止的QTextDocument(GUI的一部分) 没有提到是否使用了可以直接访问的东西(甚至是Qt核心的一部分)。因此,我研究了源代码。我从面包屑开始,跟着面包屑走 最后,我在: 以下是OP的坏消息

我有一个具有HTML4实体的输入QString,如
õ。但我在Qt中找不到任何这样做的设施。在Qt中有这样做的方法吗?如果可能,我希望避免使用
QTextDocument
,这样就不必引入QtGui

此链接中列出了HTML 4实体:


出于好奇,我四处看了看

我找到了这个。但是,它使用OP想要阻止的
QTextDocument
(GUI的一部分)

没有提到是否使用了可以直接访问的东西(甚至是Qt核心的一部分)。因此,我研究了源代码。我从面包屑开始,跟着面包屑走

最后,我在:

以下是OP的坏消息:

  • QTextHtmlParser
    的API是私有的:

    //
    //  W A R N I N G
    //  -------------
    //
    // This file is not part of the Qt API.  It exists purely as an
    // implementation detail.  This header file may change from version to
    // version without notice, or even be removed.
    //
    // We mean it.
    //
    
  • 它是QtGUI的一部分

  • 如果OP坚持阻止GUI依赖,我看到的唯一其他机会就是复制代码(或者从头开始重新实现代码)

    static const struct QTextHtmlEntity { const char name[9]; quint16 code; } entities[]= {
        { "AElig", 0x00c6 },
        { "AMP", 38 },
    
        { "zwj", 0x200d },
        { "zwnj", 0x200c }
    };
    Q_STATIC_ASSERT(MAX_ENTITY == sizeof entities / sizeof *entities);
    
    //
    //  W A R N I N G
    //  -------------
    //
    // This file is not part of the Qt API.  It exists purely as an
    // implementation detail.  This header file may change from version to
    // version without notice, or even be removed.
    //
    // We mean it.
    //