Question: I have this char in an xml file:

```
<data>
  <products>
      <color>fumè</color>
  </product>
</data>

```

I try to generate an instance of ElementTree with the following code:

```
string_data = open('file.xml')
x = ElementTree.fromstring(unicode(string_data.encode('utf-8')))

```

and I get the following error:

```
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 185: ordinal not in range(128)

```

*(NOTE: The position is not exact, I sampled the xml from a larger one).*

How to solve it? Thanks

Answer: 
You need to **decode** utf-8 strings into a unicode object. So

```
string_data.encode('utf-8')

```

should be

```
string_data.decode('utf-8')

```

assuming `string_data` is actually an utf-8 string.

So to summarize: To get an utf-8 string from a unicode object you **encode** the unicode (using the utf-8 encoding), and to turn a string to a unicode object you **decode** the string using the respective encoding.

For more details on the concepts I suggest reading [The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets](http://www.joelonsoftware.com/articles/Unicode.html) (not Python specific).
Function `open()` does not return a `string`. 
Instead use `open('file.xml').read()`.