File indexing completed on 2024-04-21 14:53:56

0001 /*
0002     This file is part of the KDE libraries
0003 
0004     SPDX-FileCopyrightText: 1999 Lars Knoll <knoll@kde.org>
0005     SPDX-FileCopyrightText: 2001, 2003, 2004, 2005, 2006 Nicolas GOUTTE <goutte@kde.org>
0006     SPDX-FileCopyrightText: 2007 Nick Shaforostoff <shafff@ukr.net>
0007 
0008     SPDX-License-Identifier: LGPL-2.0-or-later
0009 */
0010 
0011 #ifndef KCHARSETS_P_H
0012 #define KCHARSETS_P_H
0013 
0014 #include "kcharsets.h"
0015 #include "kusasciitextcodec.h"
0016 
0017 #include <QHash>
0018 #include <QTextCodec>
0019 
0020 class KCharsetsPrivate
0021 {
0022 public:
0023     explicit KCharsetsPrivate(KCharsets *_kc)
0024         : usAsciiTextCodec{new KUsAsciiTextCodec}
0025     {
0026         kc = _kc;
0027         codecForNameDict.reserve(43);
0028     }
0029 
0030     bool isUsAsciiTextCodecRequest(const QByteArray &name) const;
0031 
0032     // Hash for the encoding names (sensitive case)
0033     QHash<QByteArray, QTextCodec *> codecForNameDict;
0034     KCharsets *kc;
0035     // Using own variant due to broken ICU-based Qt codec, see QTBUG-83081.
0036     // US-ASCII being an important one, but perhaps others also need their variant here?
0037     // The life-time management is handled by Qt itself by
0038     // auto-registration inside the QTextCodec constructor.
0039     QTextCodec *const usAsciiTextCodec;
0040 
0041     // Cache list so QStrings can be implicitly shared
0042     QList<QStringList> encodingsByScript;
0043 
0044     KCODECS_EXPORT QTextCodec *codecForName(const QString &n);
0045     KCODECS_EXPORT QTextCodec *codecForName(const QString &n, bool &ok);
0046     QTextCodec *codecForNameOrNull(const QByteArray &n);
0047 };
0048 
0049 #endif