On Saturday 24 April 2010 13:16:20 Glenn Linderman wrote: > On 4/23/2010 6:02 PM, [email protected] wrote: > > I've got a small program that parses a web page and outputs a small > > amount of text to a QTextLabel. The problem is, that when displaying > > numbers with spaces between them, the textLabel seems to add in strange > > characters. Example: http://everydaylht.com/example.png > > > > The string should be "6 272 640 square inches". This is how the string > > looks when I parse the webpage. If I print the string before it is > > displayed, the terminal output is how it should be (ie. 6 272 640 square > > inches). However, in a QTextLabel, those weird A's get inserted. > > > > The source file uses UTF-8 encoding. > > > > Any suggestions what this might be, or how it might be fixed. > > > > The relevant code is here: http://pastebin.org/171738 > > > > Thanks > > > > Matt > > Weird As sound like an encoding problem... like passing UTF-8 to > something that is expecting Latin-1. > > I wonder, too, if your spaces are actually "hard spaces" (code 0xA0), > which would be subject to such an encoding issue, even though all the > visible text appears to be ASCII, and so thus not affected by weird > encoding problems. > > Fixing the encoding would be the right solution; converting hard spaces > to regular spaces would be a workaround and might cause unintended line > breaks (probably not a problem from your screen shot, but perhaps not a > good general rule). > > You don't mention if you are using Python 2 or 3, or what the encoding > of the web page is... but maybe this will get you started down the right > path.
Thanks for your help. I thought it was an encoding problem too. I'm using python 2.6.2. How do I find out the encoding of the web page? Doesn't appear to be in the source. The other problem I have, is that I'm not sure how to fix the encoding once I've worked it out what the encoding of the web page is. I'm a bit of a newb, and am not sure exactly how this encoding thing works. Cheers Matt _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
