File indexing completed on 2025-01-05 04:26:48
0001 /* 0002 * Replacement fot QT Bindings that were removed from QT5 0003 * Copyright (C) 2020 Pedro de Carvalho Gomes <pedrogomes81@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 */ 0018 0019 #include "CoreTextCodec.h" 0020 0021 #include <QJSEngine> 0022 0023 using namespace QtBindings::Core; 0024 0025 TextCodec::TextCodec() : TextCodec( nullptr ) 0026 { 0027 } 0028 0029 TextCodec::TextCodec(const QTextCodec *codec) 0030 { 0031 if ( codec != nullptr ) { 0032 internal = codec; 0033 } else { 0034 internal = QTextCodec::codecForLocale(); 0035 } 0036 } 0037 0038 TextCodec::TextCodec(const TextCodec &codec) : TextCodec( dynamic_cast<const QTextCodec*>(&codec) ) 0039 { 0040 } 0041 0042 TextCodec::~TextCodec() 0043 { 0044 } 0045 0046 QList<QByteArray> TextCodec::aliases() const 0047 { 0048 return internal->aliases(); 0049 } 0050 0051 bool TextCodec::canEncode(QChar ch) const 0052 { 0053 return internal->canEncode(ch); 0054 } 0055 0056 bool TextCodec::canEncode(const QString &s) const 0057 { 0058 return internal->canEncode(s); 0059 } 0060 0061 ByteArray TextCodec::fromUnicode(const QString &str) const 0062 { 0063 return ByteArray( internal->fromUnicode(str) ); 0064 } 0065 0066 ByteArray 0067 TextCodec::fromUnicode(const QChar *input, int number, QTextCodec::ConverterState *state) const 0068 { 0069 return ByteArray( internal->fromUnicode(input, number, state) ); 0070 } 0071 0072 /* 0073 QTextDecoder *TextCodec::makeDecoder(QTextCodec::ConversionFlags flags) const 0074 { 0075 return internal->makeDecoder(flags); 0076 } 0077 0078 QTextEncoder *TextCodec::makeEncoder(QTextCodec::ConversionFlags flags) const 0079 { 0080 return internal->makeEncoder(flags); 0081 } 0082 */ 0083 0084 int TextCodec::mibEnum() 0085 { 0086 return internal->mibEnum(); 0087 } 0088 0089 ByteArray TextCodec::name() 0090 { 0091 return ByteArray( internal->name() ); 0092 } 0093 0094 QString TextCodec::toUnicode(const ByteArray &a) const 0095 { 0096 return internal->toUnicode(a); 0097 } 0098 0099 QString TextCodec::toUnicode(const char *chars) const 0100 { 0101 return internal->toUnicode(chars); 0102 } 0103 0104 QString 0105 TextCodec::toUnicode(const char *input, int size, QTextCodec::ConverterState *state) const 0106 { 0107 return internal->toUnicode(input, size, state); 0108 } 0109 0110 QList<QByteArray> TextCodec::availableCodecs() 0111 { 0112 return QTextCodec::availableCodecs(); 0113 } 0114 0115 QList<int> TextCodec::availableMibs() 0116 { 0117 return QTextCodec::availableMibs(); 0118 } 0119 0120 TextCodec TextCodec::codecForHtml(const ByteArray &ba, QTextCodec *defaultCodec) 0121 { 0122 return TextCodec( QTextCodec::codecForHtml(ba,defaultCodec) ); 0123 } 0124 0125 TextCodec TextCodec::codecForHtml(const ByteArray &ba) 0126 { 0127 return QTextCodec::codecForHtml(ba); 0128 } 0129 0130 TextCodec TextCodec::codecForLocale() 0131 { 0132 return QTextCodec::codecForLocale(); 0133 } 0134 0135 TextCodec TextCodec::codecForMib(int mib) 0136 { 0137 return QTextCodec::codecForMib(mib); 0138 } 0139 0140 TextCodec TextCodec::codecForName(const ByteArray &name) 0141 { 0142 return QTextCodec::codecForName(name); 0143 } 0144 0145 TextCodec TextCodec::codecForName(const char *name) 0146 { 0147 return QTextCodec::codecForName(name); 0148 } 0149 0150 TextCodec TextCodec::codecForUtfText(const ByteArray &ba, QTextCodec *defaultCodec) 0151 { 0152 return QTextCodec::codecForUtfText(ba,defaultCodec); 0153 } 0154 0155 TextCodec TextCodec::codecForUtfText(const ByteArray &ba) 0156 { 0157 return QTextCodec::codecForUtfText(ba); 0158 } 0159 0160 void TextCodec::setCodecForLocale(QTextCodec *c) 0161 { 0162 QTextCodec::setCodecForLocale(c); 0163 } 0164 0165 TextCodec &TextCodec::operator=(const TextCodec &other) 0166 { 0167 if (this != &other) { 0168 internal = other.internal; 0169 } 0170 return *this; 0171 }