On 7/17/09 9:19 PM, saeed wrote:
Another way:

data = '&#xE1'
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
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to