[PyQt] Python3 Qt4 and string encoding issues

Phil Thompson phil at riverbankcomputing.com
Tue Apr 15 18:28:45 BST 2014


On 15-04-2014 12:32 pm, rohan at kde.org wrote:
>> Just a small follow up, the string is correctly encoded in the 
>> combobox , so
>> it's only the conversion back from a QString to a python string that 
>> is
>> troublesome.
>>
>> Cheers
>> Rohan Garg
>
> Harald Sitter (CC'd) wrote a patch that potentially solves this issue 
> :
>
> Index: python-qt4-4.10.4+dfsg/qpy/QtCore/qpycore_qstring.cpp
> ===================================================================
> --- 
> python-qt4-4.10.4+dfsg.orig/qpy/QtCore/qpycore_qstring.cpp	2014-03-14
> 15:19:06.000000000 +0100
> +++ python-qt4-4.10.4+dfsg/qpy/QtCore/qpycore_qstring.cpp	2014-04-15
> 13:28:50.022157511 +0200
> @@ -82,6 +82,7 @@
>
>              do
>              {
> +                uch = qch->unicode(); // Keep updating the uch, as
> the qch is
> also changing.
>                  if (uch > 0x00ff)
>                  {
>                      if (maxchar == 0x00ff)
> @@ -93,12 +94,12 @@
>                      {
>                          maxchar = 0x10ffff;
>                          --py_len;
> -                        ++i;
> -                        ++qch;
> +                        ++qch; // Upping twice here as it is a pair.
>                      }
>                  }
> +                ++qch;
>              }
> -            while (++i < qstr.length());
> +            while (!qch->isNull());
>
>              // Create the correctly sized object.
>              if ((obj = PyUnicode_New(py_len, maxchar)) == NULL)
>
>
> Could someone review this?
>
> Cheers
> Rohan Garg

Seems Ok, though I've tweaked it slightly.

Thanks,
Phil


More information about the PyQt mailing list