On Thu, Aug 8, 2013 at 5:16 PM, Kurt Mueller
<kurt.alfred.muel...@gmail.com> wrote:
> Am 08.08.2013 17:44, schrieb Peter Otten:
>> Kurt Mueller wrote:
>>> What do I do, when input_strings/output_list has other codings like
>>> iso-8859-1?
>>
>> You have to know the actual encoding. With that information it's easy:
>>>>> output_list
>> ['\xc3\xb6', '\xc3\xbc', 'i', 's', 'f']
>>>>> encoding = "utf-8"
>>>>> output_list = [s.decode(encoding) for s in output_list]
>>>>> print output_list
>> [u'\xf6', u'\xfc', u'i', u's', u'f']
>
> How do I get to know the actual encoding?
> I read from stdin. There can be different encondings.
> Usually utf8 but also iso-8859-1/latin9 are to be expected.
> But sys.stdin.encoding sais always 'None'.

If you can switch to Python 3, life becomes a LOT easier. The Python 3
input() function (which does the same job as raw_input() from Python
2) returns a Unicode string, meaning that it takes care of encodings
for you.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to