pyqt  

Re: [PyQt] Accented characters

Christoph Burgmer
Fri, 02 May 2008 02:39:44 -0700

Am Donnerstag, 1. Mai 2008 schrieb alteo_gange:
> Le jeudi 01 mai 2008, alteo_gange a écrit :
> > Hi,
> >
> > could you complete the next bit of code please?
> >
> > 1) File selection (the file's name is accented: ex. animé.txt)
> > file = QFileDialog.getOpenFileName(None, "Open"),".","All files (*.*))
> > 2) Print file's name in a terminal
> > ???
> >
> > It seems easy... too easy...
>
> print a.toUtf8()
> -> /home/login/animé.txt

If I'm not wrong this "trick" will only work for people who use utf8 as 
default encoding.

You may want to read about Python's way of dealing with encodings and Unicode, 
but that's off topic here.

Little hint:

_, system_encoding = locale.getdefaultlocale()

print unicode(your_string).encode(system_encoding)

Christoph

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt