Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.069 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'encoding': 0.05; 'expected.': 0.09; 'kurt': 0.12; 'encoding.': 0.16; 'utf8': 0.16; 'do,': 0.16; 'wrote:': 0.18; 'print': 0.22; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'usually': 0.31; '>>>>': 0.31; 'actual': 0.34; 'but': 0.35; 'there': 0.35; 'message- id:@gmail.com': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'read': 0.60; 'information': 0.63; 'different': 0.65; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'reply-to:addr:gmail.com': 0.80 X-Virus-Scanned: amavisd-new at aerodynamics.ch Date: Thu, 08 Aug 2013 18:16:40 +0200 From: Kurt Mueller Organization: Rothenburg User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: python-list@python.org Subject: Re: right adjusted strings containing umlauts References: <9781df99-f9c8-4217-aa67-7a714b7f2ebe@googlegroups.com> <5203B841.4060304@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: kurt.alfred.mueller@gmail.com List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375978647 news.xs4all.nl 15989 [2001:888:2000:d::a6]:40998 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52207 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'. TIA -- Kurt Mueller