[pygtk] Problem in fetching Unicode from URL and displaying it in PyGTK widget
Bertrand Kintanar
b3rxkintanar at gmail.com
Fri Jul 17 21:42:39 WST 2009
On 7/17/09 9:19 PM, saeed wrote:
> Another way:
>
> data = 'á'
> uni = unichr(int(data[3:], 16))
> st = uni.encode('utf-8')
>
>
>> thanks saeed! that works great! how can i make this work if the character to be converted is found between characters. e.g. Guzán ?
>>
>
> s1 = 'Guzán'
> s2 = ''
> n = len(s1)
> i = 0
> while i<n:
> if i<n-6:
> if s1[i:i+3]=='&#x' and s1[i+5]==';':
> s2 += unichr(int(s1[i+3:i+5], 16)).encode('utf-8')
> i += 6
> continue
> s2 += s1[i]
> i += 1
> print s2
>
>
>
Now this fixes it all. Thanks alot. I hope there is some sexier way to
do this though. but this will work. thanks again
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20090717/a1215612/attachment.htm
More information about the pygtk
mailing list