I'm using Python 2.7
I'm reading a file containing "iso-8859-1" coded information.
After parsing, I get the results in strings, ie s1
:
>>> s1
'D\xf6rfli'
>>> type(s1)
<type 'str'>
>>> s2=s1.decode("iso-8859-1").encode("utf8")
>>> s2
'D\xc3\xb6rfli'
>>> type(s2)
<type 'str'>
>>> print s1, s2
D�rfli Dörfli
>>>
Why is the type of s2
still a str
after the call to .encode
?
How can I convert it from str
to utf-8
?