Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.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.091 X-Spam-Evidence: '*H*': 0.82; '*S*': 0.01; 'string': 0.09; 'python': 0.11; 'kurt': 0.12; '__future__': 0.16; 'unicode.': 0.16; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'linux': 0.33; 'guess': 0.33; "i'd": 0.34; 'but': 0.35; 'right?': 0.36; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'reply- to:addr:gmail.com': 0.80; 'characters,': 0.84 X-Virus-Scanned: amavisd-new at aerodynamics.ch Date: Thu, 08 Aug 2013 16:23:46 +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: right adjusted strings containing umlauts Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375972418 news.xs4all.nl 15986 [2001:888:2000:d::a6]:32983 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52198 I'd like to print strings right adjusted. ( Python 2.7.3, Linux 3.4.47-2.38-desktop ) from __future__ import print_function print( '>{0:>3}<'.format( 'a' ) ) > a< But if the string contains an Umlaut: print( '>{0:>3}<'.format( '=C3=A4' ) ) > =C3=A4< Same with % notation: print( '>%3s<' % ( 'a' ) ) > a< print( '>%3s<' % ( '=C3=A4' ) ) > =C3=A4< For a string with no Umlaut it uses 3 characters, but for an Umlaut it uses only 2 characters. I guess it has to to with unicode. How do I get it right? TIA --=20 Kurt Mueller