diff options
author | Michele Calgaro <[email protected]> | 2023-01-04 11:15:00 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2023-01-04 16:37:05 +0900 |
commit | d31a084fc83d47eef6c6eb3aac76989da9692853 (patch) | |
tree | 2a412325bd788cd505bb5cdad90ac498a004e405 | |
parent | 30954661009ddfb9db2e9daed3bfbd594bb20441 (diff) | |
download | pytqt-d31a084fc83d47eef6c6eb3aac76989da9692853.tar.gz pytqt-d31a084fc83d47eef6c6eb3aac76989da9692853.zip |
Use utf8 instead of latin1/ascii as default. Address pyuic compatibility with python3.
Signed-off-by: Michele Calgaro <[email protected]>
-rw-r--r-- | pylupdate3/main.cpp | 6 | ||||
-rw-r--r-- | pylupdate3/metatranslator.cpp | 14 | ||||
-rw-r--r-- | pylupdate3/numberh.cpp | 2 | ||||
-rw-r--r-- | pyuic3/embed.cpp | 2 | ||||
-rw-r--r-- | pyuic3/form.cpp | 2 | ||||
-rw-r--r-- | pyuic3/main.cpp | 4 | ||||
-rw-r--r-- | pyuic3/object.cpp | 4 | ||||
-rw-r--r-- | pyuic3/parser.cpp | 2 | ||||
-rw-r--r-- | pyuic3/subclassing.cpp | 2 | ||||
-rw-r--r-- | pyuic3/uic.cpp | 4 | ||||
-rw-r--r-- | sip/qt/qapplication.sip | 2 | ||||
-rw-r--r-- | sip/qt/qimage.sip | 6 | ||||
-rw-r--r-- | sip/qt/qobject.sip | 8 | ||||
-rw-r--r-- | sip/qt/qstring.sip | 2 | ||||
-rw-r--r-- | sip/qt/qstrlist.sip | 2 |
15 files changed, 31 insertions, 31 deletions
diff --git a/pylupdate3/main.cpp b/pylupdate3/main.cpp index 8b0c24c..a3a0f3f 100644 --- a/pylupdate3/main.cpp +++ b/pylupdate3/main.cpp @@ -118,7 +118,7 @@ int main( int argc, char **argv ) translatorFiles.append( *t ); metSomething = TRUE; } else if ( it.key() == TQString("CODEC") ) { - codec = (*t).latin1(); + codec = (*t).utf8(); } } } @@ -129,13 +129,13 @@ int main( int argc, char **argv ) if ( !codec.isEmpty() ) tor.setCodec( codec ); if ( verbose ) - tqWarning( "Updating '%s'...", (*tf).latin1() ); + tqWarning( "Updating '%s'...", (*tf).utf8() ); merge( &tor, &fetchedTor, verbose ); if ( noObsolete ) tor.stripObsoleteMessages(); tor.stripEmptyContexts(); if ( !tor.save(*tf) ) - tqWarning( "pylupdate error: Cannot save '%s': %s", (*tf).latin1(), + tqWarning( "pylupdate error: Cannot save '%s': %s", (*tf).utf8(), strerror(errno) ); } if ( !metSomething ) { diff --git a/pylupdate3/metatranslator.cpp b/pylupdate3/metatranslator.cpp index 67b9ca6..f46ee9a 100644 --- a/pylupdate3/metatranslator.cpp +++ b/pylupdate3/metatranslator.cpp @@ -139,8 +139,8 @@ bool TsHandler::endElement( const TQString& /* namespaceURI */, accum.utf8(), TQString::null, TRUE, MetaTranslatorMessage::Unfinished) ); else - tor->insert( MetaTranslatorMessage(context.ascii(), "", - accum.ascii(), TQString::null, FALSE, + tor->insert( MetaTranslatorMessage(context.local8Bit(), "", + accum.local8Bit(), TQString::null, FALSE, MetaTranslatorMessage::Unfinished) ); } } else if ( qName == TQString("translation") ) { @@ -151,8 +151,8 @@ bool TsHandler::endElement( const TQString& /* namespaceURI */, comment.utf8(), translation, TRUE, type) ); else - tor->insert( MetaTranslatorMessage(context.ascii(), source.ascii(), - comment.ascii(), translation, + tor->insert( MetaTranslatorMessage(context.local8Bit(), source.local8Bit(), + comment.local8Bit(), translation, FALSE, type) ); inMessage = FALSE; } @@ -173,9 +173,9 @@ bool TsHandler::fatalError( const TQXmlParseException& exception ) TQString msg; msg.sprintf( "Parse error at line %d, column %d (%s).", exception.lineNumber(), exception.columnNumber(), - exception.message().latin1() ); + exception.message().utf8() ); if ( tqApp == 0 ) - tqWarning( "XML error: %s", msg.latin1() ); + tqWarning( "XML error: %s", msg.utf8() ); else TQMessageBox::information( tqApp->mainWidget(), TQObject::tr("TQt Linguist"), msg ); @@ -226,7 +226,7 @@ static TQString evilBytes( const TQCString& str, bool utf8 ) return protect( str ); } else { TQString result; - TQCString t = protect( str ).latin1(); + TQCString t = protect( str ).utf8(); int len = (int) t.length(); for ( int k = 0; k < len; k++ ) { if ( (uchar) t[k] >= 0x7f ) diff --git a/pylupdate3/numberh.cpp b/pylupdate3/numberh.cpp index e5ff5de..a52687b 100644 --- a/pylupdate3/numberh.cpp +++ b/pylupdate3/numberh.cpp @@ -140,7 +140,7 @@ static TQString translationAttempt( const TQString& oldTranslation, for ( k = 0; k < p; k++ ) { if ( (!met[k] || pass > 0) && matchedYet[k] == (int) oldNumbers[k].length() && - numberLength(oldTranslation.latin1() + (i + 1) - + numberLength(oldTranslation.utf8() + (i + 1) - matchedYet[k]) == matchedYet[k] ) { // the longer the better if ( best == p || matchedYet[k] > matchedYet[best] ) diff --git a/pyuic3/embed.cpp b/pyuic3/embed.cpp index 3a66de3..c54104f 100644 --- a/pyuic3/embed.cpp +++ b/pyuic3/embed.cpp @@ -149,7 +149,7 @@ void Uic::embed( TQTextStream& out, const char* project, const TQStringList& ima for ( it = images.begin(); it != images.end(); ++it ) { TQImage img; if ( !img.load( *it ) ) { - fprintf( stderr, "pyuic: cannot load image file %s\n", (*it).latin1() ); + fprintf( stderr, "pyuic: cannot load image file %s\n", (*it).utf8() ); continue; } EmbedImage *e = new EmbedImage; diff --git a/pyuic3/form.cpp b/pyuic3/form.cpp index 752c281..8c7a374 100644 --- a/pyuic3/form.cpp +++ b/pyuic3/form.cpp @@ -877,7 +877,7 @@ void Uic::createFormImpl( const TQDomElement &e ) out << endl; ++indent; if ( *cit != "init()" && *cit != "destroy()" ) - out << indent << "print \"" << nameOfClass << "." << (*cit) << ": Not implemented yet\"" << endl; + out << indent << "print(\"" << nameOfClass << "." << (*cit) << ": Not implemented yet\")" << endl; else out << indent << "pass" << endl; --indent; diff --git a/pyuic3/main.cpp b/pyuic3/main.cpp index 43c9d7b..e54000c 100644 --- a/pyuic3/main.cpp +++ b/pyuic3/main.cpp @@ -172,7 +172,7 @@ int main( int argc, char * argv[] ) TQTextStream out( &fileOut ); if ( imagecollection ) { - out.setEncoding( TQTextStream::Latin1 ); + out.setEncoding( TQTextStream::UnicodeUTF8 ); out << "# -*- coding: latin-1 -*-\n\n"; Uic::embed( out, projectName, images ); return 0; @@ -193,7 +193,7 @@ int main( int argc, char * argv[] ) TQDomElement e = doc.firstChild().toElement(); if ( e.hasAttribute("version") && e.attribute("version").toDouble() > 3.3 ) { tqWarning( TQString("pyuic: File generated with too recent version of TQt Designer (%s vs. %s)"), - e.attribute("version").latin1(), TQT_VERSION_STR ); + e.attribute("version").utf8(), TQT_VERSION_STR ); return 1; } diff --git a/pyuic3/object.cpp b/pyuic3/object.cpp index 5ee2b73..1b7232f 100644 --- a/pyuic3/object.cpp +++ b/pyuic3/object.cpp @@ -247,7 +247,7 @@ TQString Uic::createObjectImpl( const TQDomElement &e, const TQString& parentCla TQString page = createObjectImpl( n, objClass, fullObjName ); TQString comment; TQString label = DomTool::readAttribute( n, "title", "", comment ).toString(); - out << indent << fullObjName << ".insertTab(" << page << ",TQString.fromLatin1(\"\"))" << endl; + out << indent << fullObjName << ".insertTab(" << page << ",TQString.fromUtf8(\"\"))" << endl; trout << trindent << fullObjName << ".changeTab(" << page << "," << trcall( label, comment ) << ")" << endl; } } @@ -265,7 +265,7 @@ TQString Uic::createObjectImpl( const TQDomElement &e, const TQString& parentCla TQString page = createObjectImpl( n, objClass, fullObjName ); TQString comment; TQString label = DomTool::readAttribute( n, "label", "", comment ).toString(); - out << indent << fullObjName << ".addItem(" << page << ",TQString.fromLatin1(\"\"))" << endl; + out << indent << fullObjName << ".addItem(" << page << ",TQString.fromUtf8(\"\"))" << endl; trout << trindent << fullObjName << ".setItemLabel(" << fullObjName << ".indexOf(" << page << ")," << trcall( label, comment ) << ")" << endl; diff --git a/pyuic3/parser.cpp b/pyuic3/parser.cpp index 85446fa..fc6aae4 100644 --- a/pyuic3/parser.cpp +++ b/pyuic3/parser.cpp @@ -62,5 +62,5 @@ TQString Parser::cleanArgs( const TQString &func ) } res += ")"; - return TQString::fromLatin1( NormalizeObject::normalizeSignalSlot( res.latin1() ) ); + return TQString::fromUtf8( NormalizeObject::normalizeSignalSlot( res.utf8() ) ); } diff --git a/pyuic3/subclassing.cpp b/pyuic3/subclassing.cpp index 143a27a..9cb1ee1 100644 --- a/pyuic3/subclassing.cpp +++ b/pyuic3/subclassing.cpp @@ -178,7 +178,7 @@ void Uic::writeFunctionsSubImpl( const TQStringList &fuLst, const TQStringList & pySlot(it); ++indent; out << endl; - out << indent << "print \"" << subClass << "." << (*it) << ": Not implemented yet\"" << endl; + out << indent << "print(\"" << subClass << "." << (*it) << ": Not implemented yet\")" << endl; --indent; } out << endl; diff --git a/pyuic3/uic.cpp b/pyuic3/uic.cpp index ac6af9b..8d0613c 100644 --- a/pyuic3/uic.cpp +++ b/pyuic3/uic.cpp @@ -249,7 +249,7 @@ Uic::Uic( const TQString &fn, const char *outputFn, TQTextStream &outStream, out << "\n"; out << indent << "def __tr(self,s,c = None):\n"; ++indent; - out << indent << "return tqApp.translate(\"" << nameOfClass << "\",s,c)\n"; + out << indent << "return tqApp.translate(b\"" << nameOfClass << "\",s.encode(),c)\n"; --indent; } @@ -258,7 +258,7 @@ Uic::Uic( const TQString &fn, const char *outputFn, TQTextStream &outStream, out << "\n"; out << indent << "def __trUtf8(self,s,c = None):\n"; ++indent; - out << indent << "return tqApp.translate(\"" << nameOfClass << "\",s,c,TQApplication.UnicodeUTF8)\n"; + out << indent << "return tqApp.translate(b\"" << nameOfClass << "\",s.encode(),c,TQApplication.UnicodeUTF8)\n"; --indent; } diff --git a/sip/qt/qapplication.sip b/sip/qt/qapplication.sip index dcf333d..d9247d9 100644 --- a/sip/qt/qapplication.sip +++ b/sip/qt/qapplication.sip @@ -374,7 +374,7 @@ static char **pyArgvToC(PyObject *argvlist,int &argc) if (PyUnicode_Check(argObject)) { - arg = tqstrdup(sipString_AsLatin1String(&argObject)); + arg = tqstrdup(sipString_AsUTF8String(&argObject)); } else if (SIPBytes_Check(argObject)) { diff --git a/sip/qt/qimage.sip b/sip/qt/qimage.sip index b1628c5..9fb7907 100644 --- a/sip/qt/qimage.sip +++ b/sip/qt/qimage.sip @@ -432,15 +432,15 @@ const char **PyTQt_qt_ListToArray(PyObject *lst) for (int i = 0; i < nstr; ++i) { PyObject *item = PyList_GetItem(lst, i); - const char *item_ascii = sipString_AsASCIIString(&item); + const char *item_utf8 = sipString_AsUTF8String(&item); - if (item_ascii == NULL) + if (item_utf8 == NULL) { sipFree((void *)str); return NULL; } - *sp++ = item_ascii; + *sp++ = item_utf8; } return str; diff --git a/sip/qt/qobject.sip b/sip/qt/qobject.sip index df82e56..b6e0387 100644 --- a/sip/qt/qobject.sip +++ b/sip/qt/qobject.sip @@ -369,11 +369,11 @@ public: } else { - const char *source = sipString_AsLatin1String(&a0); + const char *source = sipString_AsUTF8String(&a0); if (source) { - sipRes = new TQString(QString::fromLatin1(source)); + sipRes = new TQString(QString::fromUtf8(source)); Py_DECREF(a0); } else @@ -402,11 +402,11 @@ public: } else { - const char *source = sipString_AsLatin1String(&a0); + const char *source = sipString_AsUTF8String(&a0); if (source) { - sipRes = new TQString(TQString::fromLatin1(source)); + sipRes = new TQString(TQString::fromUtf8(source)); Py_DECREF(a0); } else diff --git a/sip/qt/qstring.sip b/sip/qt/qstring.sip index 13bf0a1..d06fec1 100644 --- a/sip/qt/qstring.sip +++ b/sip/qt/qstring.sip @@ -831,7 +831,7 @@ TQString *PyTQt_qt_PyObject_AsTQString(PyObject *obj) switch (PyUnicode_KIND(obj)) { case PyUnicode_1BYTE_KIND: - return new TQString(TQString::fromLatin1((char *)PyUnicode_1BYTE_DATA(obj), len)); + return new TQString(TQString::fromUtf8((char *)PyUnicode_1BYTE_DATA(obj), len)); case PyUnicode_2BYTE_KIND: // The (TQChar *) cast should be safe. diff --git a/sip/qt/qstrlist.sip b/sip/qt/qstrlist.sip index 695c872..2a35b65 100644 --- a/sip/qt/qstrlist.sip +++ b/sip/qt/qstrlist.sip @@ -85,7 +85,7 @@ is used instead. if (PyUnicode_Check(object)) { - s = tqstrdup(sipString_AsLatin1String(&object)); + s = tqstrdup(sipString_AsUTF8String(&object)); } else if ((s = (char *)sipBytes_AsString(object)) == NULL) { |