2010-04-16, 15:53
Im going mad...
I have a big trouble working with strings with special caracters.
An example of my problem:
Problem is n == Exámple returns FALSE but n=Exámple and print n prints Exámple.
I know problem is the special caracter "á" and i tried to encode and decode to utf-8 the variable name.
If i try:
I have a seriuos problem with codification, i need help with this.
Another problem (but i think is the same problem with the same solution) is when I have a label and i setLabel a word with especial caracter, if i only set the variable with special caracter, lableel shows perfect. Example:
My scraper have the line # -*- coding: utf-8 -*- on top.
Im going mad with this problem....
Anyone could help me please??
Thanks in advance.
I have a big trouble working with strings with special caracters.
An example of my problem:
Code:
list.append("Exámple")
seleccion= xbmcgui.Dialog()
number= seleccion.select(selecciona,list)
name = list[number]
Code:
print name
=
Exámple
Code:
self.functionExample(name)
Code:
def functionExample(self,n):
if n=="Exámple":
print "WORKS WELL"
Problem is n == Exámple returns FALSE but n=Exámple and print n prints Exámple.
I know problem is the special caracter "á" and i tried to encode and decode to utf-8 the variable name.
If i try:
Code:
name=name.encode("utf-8")
ascii' codec can't decode byte in position 3: ordinal not in range(128)
name=name.decode("utf-8")
utf8' codec can't decode bytes in position : invalid data
I have a seriuos problem with codification, i need help with this.
Another problem (but i think is the same problem with the same solution) is when I have a label and i setLabel a word with especial caracter, if i only set the variable with special caracter, lableel shows perfect. Example:
Code:
self.getControl(self.lbl_example).setLabel(name)
lbl_example shows Exámple
BUT
self.getControl(self.lbl_example).setLabel("The name is %s",%(name))
lbl_example shows The name is Ex/..mple
My scraper have the line # -*- coding: utf-8 -*- on top.
Im going mad with this problem....
Anyone could help me please??
Thanks in advance.