Hey everyone,
I'm trying to encode some unicode in a label expression using the python parser and defining a function. I'm geting a weird unicode value being returned and I can't figure out why.
In the following code:
Where the field [Unicode_Value] contains records that have unicoding strings for each record. In my case, they are all u'\u00e9' which is the code for é
Instead, it returns 'Libertesri__0'
This should return 'Liberté' as the encoding on my computer is set to 'cp1252' the US Standard. I can get this to work if I hard code the é unicode value into the function like this:
but somehow I think the file geodatabase feature class attribute table is throwing some ESRI unicoding when I use the field in my function.
can anyone suggest how I can fix this?
Thanks,
Mike
I'm trying to encode some unicode in a label expression using the python parser and defining a function. I'm geting a weird unicode value being returned and I can't figure out why.
In the following code:
Code:
def FindLabel ([Unicode_Value]):
import locale
deflang, defencoding = locale.getdefaultlocale()
S = u'Libert{}'.format(u'[Unicode_Value]'.encode(defencoding))
return S
Instead, it returns 'Libertesri__0'
This should return 'Liberté' as the encoding on my computer is set to 'cp1252' the US Standard. I can get this to work if I hard code the é unicode value into the function like this:
Code:
S = u'Libert{}'.format(u'\u00e9'.encode(defencoding))
can anyone suggest how I can fix this?
Thanks,
Mike