AnsweredAssumed Answered

Managing UTF-8 encoded fields in field calculation

Question asked by prototron on Jun 16, 2016
Latest reply on Jun 16, 2016 by prototron

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"

Outcomes