PyQT: QString to String Problem if ASCII>128

Jason Orendorff jason at jorendorff.com
Mon Mar 11 02:46:15 EST 2002


Ingo Linkweiler wrote:
> no ideas?
> 
> I found a possible solution, but is this the best way?
> 
>     uc=self.edit.text()
>     try:
>       t=str(uc)
>     except:
>       try:
>         t=unicode(self.edit.text()).encode("cp437")
>       except:
>         t="invalid char in string"

I guess you want something like

uc = self.edit.text()
t = unicode(uc).encode("cp437", errors="replace")

I can't test it here, though.

## Jason Orendorff    http://www.jorendorff.com/




More information about the Python-list mailing list