[PyQt] UTF-8 files handling in PyQT4

Roberto Alsina ralsina at kde.org
Sat May 5 16:44:30 BST 2007

On Sat 05 May 2007 12:23:49 piotr maliński wrote:
> That doesn't help. It won't even open a file:
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position
> 14: ordinal not in range(128)
> It wants to use ASCII "codec". I've noticed that for example
> QTextStream has "setCodec" but there isn't anything about encoding for
> QFile or textEdit.

Sorry, I haven't followed the thread, but... maybe you need to open the file 
using the codecs module instead of plain open()?


I know this works :-)

 ("\''/").__..-''"`-. .         Roberto Alsina
 `9_ 9  )   `-. (    ).`-._.`)  ralsina at kde.org
 (_Y_.)' ._   ) `._`.  " -.-'   KDE Developer (MFCH)
  _..`-'_..-_/ /-'_.'
(l)-'' ((i).' ((!.'   Buenos Aires - Argentina

Debugging is twice as hard as writing the code in the first place. 
Therefore, if you write the code as cleverly as possible, you are, 
by definition, not smart enough to debug it. --Brian W. Kernighan 

More information about the PyQt mailing list