Hello,
I am trying to write a Python code block in a Field Calculation but I have problems with fields containing "é" "è", etc.
--------------------------------------------------------
ERROR 000539: Error running expression: legend_field(u"Laferrière")
Traceback (most recent call last):
File "<expression>", line 1, in <module>
File "<string>", line 5, in legend_field
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 7: ordinal not in range(128)
--------------------------------------------------------
Here is the code so far in the code block:
# -*- coding: utf-8 -*-
prop_list = []
def legend_field(prop):
if (str(prop) not in prop_list):
prop_list.append(str(prop))
return "sds"
Solved! Go to Solution.
I solved my problem by removing the str() that was wrapping prop in line 6
I also tried to .encode('utf-8') the string I am trying to append
I solved my problem by removing the str() that was wrapping prop in line 6