[pygtk] Problem in fetching Unicode from URL and displaying it in PyGTK widget
saeed
saeed.gnu at gmail.com
Fri Jul 17 21:19:21 WST 2009
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
On 7/17/09, Bertrand Kintanar <b3rxkintanar at gmail.com> wrote:
> On 7/17/09 8:23 PM, saeed wrote:
>> Use function "eval", for example:
>>
>> data = 'á'
>> uni = eval("u'\\%s'"%data[2:]) ## u'\xE1' or u'á'
>> st = uni.encode('utf-8') ## 'á'
>>
>> Is there another problem?
>>
>>
> 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 ?
>
More information about the pygtk
mailing list