[Tutor] UnicodeEncodeError in python

Juan Christian juan0christian at gmail.com
Thu Sep 11 21:37:03 CEST 2014


Forget to tell, sorry. I'm using Python 3.4.1

On Thu, Sep 11, 2014 at 3:53 PM, Sebastian Silva <sebastian at fuentelibre.org>
wrote:

> Hi,
> Python 2 suffers from these kinds of issues frequently.
>
> However Python 3 does not.
>
> Now, to deal with different encodings in Python 2 you need to cast to
> unicode type, and then decode the string into unicode.
>
> something like this:
>
> name = unicode(original_name)
> name = name.decode("utf-8")
>
> This is assuming your data source is in fact utf-8 encoded (which is the
> most likely, imhe).
>
> Hope it helps,
> Sebastian
>
> El jue, 11 de sep 2014 a las 1:43 PM, Juan Christian <
> juan0christian at gmail.com> escribió:
>
>  I'm iterating through Steam users and friend lists.
>>
>> So, my program was working good, but then I got some UnicodeEncodeError
>> randomly, I didn't know where was the problem, then I was checking the
>> names that I got from the API by hand, and then I saw users with ™, ︻デ═一,
>> ︻芫━━━━, º³® and tons of others different chars in their names...
>>
>> How can I make a "bulletproof" program against these chars? Can Python
>> read them using some sort of function?
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140911/a47d47bc/attachment.html>


More information about the Tutor mailing list