[PyQt] pylupdate patch for UTF-8 support
Giovanni Bajo
rasky at develer.com
Tue Jun 26 17:42:12 BST 2007
Hi,
this patch is needed for me to be able to correctly run pylupdate over
Python UTF-8 source code, containing UTF-8 literal strings.
The code uses self.tr() instead of self.trUtf8() and changes the
defaultCodecForTr to UTF-8 at startup. This is Trolltech's recommended
way to avoid using trUtf8 explicitly all over the code.
Also, I noted that pylupdate diverged from Trolltech's lupdate by a fair
amount. Are there plans to resync it?
--
Giovanni Bajo
-------------- next part --------------
diff -ur ..\pylupdate/fetchtr.cpp pylupdate/fetchtr.cpp
--- ..\pylupdate/fetchtr.cpp 2007-06-26 03:31:36.000000000 +0200
+++ pylupdate/fetchtr.cpp 2007-06-26 18:26:07.105558300 +0200
@@ -560,7 +560,7 @@
break;
case Tok_tr:
case Tok_trUtf8:
- utf8 = (yyTok == Tok_trUtf8);
+ utf8 = (yyTok == Tok_trUtf8 || (yyCodecForTr && strcmp(yyCodecForTr->name(), "UTF-8") == 0));
yyTok = getToken();
if (match(Tok_LeftParen) && matchString(&text))
{
diff -ur ..\pylupdate/main.cpp pylupdate/main.cpp
--- ..\pylupdate/main.cpp 2007-06-26 03:31:36.000000000 +0200
+++ pylupdate/main.cpp 2007-06-26 18:31:32.058683300 +0200
@@ -41,6 +41,7 @@
#include <qstring.h>
#include <qstringlist.h>
#include <qtextstream.h>
+#include <qtextcodec.h>
#include <errno.h>
#include <string.h>
@@ -202,6 +203,7 @@
it.key() == "DEFAULTCODEC" ||
it.key() == "CODECFORTR" ) {
codecForTr = (*t).toLatin1();
+ fetchedTor.setCodecForTr(codecForTr);
} else if ( it.key() == "CODECFORSRC" ) {
codecForSource = (*t).toLatin1();
} else if ( it.key() == "FORMS" ) {
More information about the PyQt
mailing list