Use utf8 instead of latin1/ascii as default. Address pyuic compatibility with python3.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/14/head
Michele Calgaro 1 year ago
parent 3095466100
commit d31a084fc8
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -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 ) {

@ -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 )

@ -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] )

@ -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;

@ -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;

@ -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;
}

@ -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;

@ -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() ) );
}

@ -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;

@ -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;
}

@ -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))
{

@ -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;

@ -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

@ -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.

@ -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)
{

Loading…
Cancel
Save