Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #83992

Formatting string with accented characters for printing

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.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 <jerry.rocteur@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.072
X-Spam-Evidence '*H*': 0.86; '*S*': 0.00; 'output': 0.05; 'subject:characters': 0.09; 'subject:string': 0.09; 'subject:Formatting': 0.16; 'help.': 0.21; 'print': 0.22; "i've": 0.25; 'right.': 0.26; 'tried': 0.27; 'characters': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'guess': 0.33; 'subject:with': 0.35; "can't": 0.35; 'convert': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'thanks': 0.36; 'hi,': 0.36; 'e.g.': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'first': 0.61; 'containing': 0.69; 'anne': 0.84; 'subject:printing': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=bdG9PNbcBLAsPBcX+PVXCf3rYPRtwXNicCCy4NOgRgA=; b=q0XANUL/mAa5CMViAzFiZb3z0uG0VirJsZkVsiY3Y8+JZ+yh0KxNUlDZkoaEGjem7x G5un1n42qQKCASNUaQEJDBZ3n25FilEeSx5aGye/6N7O33G2WfjYamT3zAWWDsSbTcaD 0c61fx9eB7cXvHQR8Gl563cOSGQYEI9L6Cge3QTT4TltZ+fyBhrUUDCVfK05eev2Cm8B jyO3+O05CxCnptsFX+C2Zn4qitdKJmJBO7JyKp961j5d0gTyqzdETxTCK6j6ZAjU0jA/ JByw9pcDrwW3ZwFTe5KlUvKlAn/pbnrKltavG3HvMWwxGoxU6ExBJNTSeyRjxBvhqdGh ClAQ==
X-Received by 10.152.21.134 with SMTP id v6mr25231273lae.13.1421597117384; Sun, 18 Jan 2015 08:05:17 -0800 (PST)
MIME-Version 1.0
From Jerry Rocteur <jerry.rocteur@gmail.com>
Date Sun, 18 Jan 2015 17:04:57 +0100
Subject Formatting string with accented characters for printing
To python-list@python.org
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Mailman-Approved-At Sun, 18 Jan 2015 19:08:26 +0100
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.17838.1421604508.18130.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1421604508 news.xs4all.nl 2904 [2001:888:2000:d::a6]:33442
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:83992

Show key headers only | View raw


Hi,

When I try and format output when there are accented characters the
output does not look right.

e.g.

27 Angie Dickons                       67,638
28 Anne MÉRESSE                 64,825

So the strings containing accented characters print one less than
those that don't.

I've tried both:

    print '{0:2} {1:25} {2} '.format( cnt, nam[num].encode('utf-8'),
steps[ind1])
    print "%3d %-25s %-7s" % ( cnt, nam[num].encode('utf-8'), steps[ind1])

I've searched but I can't see a solution..

I guess it is the way I'm printing nam[num].encode('utf-8') perhaps I
have to convert it first ?

Can someone please help.

Thanks

-- 
Jerry Rocteur

Jerry@rocteur.com

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Formatting string with accented characters for printing Jerry Rocteur <jerry.rocteur@gmail.com> - 2015-01-18 17:04 +0100
  Re: Formatting string with accented characters for printing John Ladasky <john_ladasky@sbcglobal.net> - 2015-01-27 11:16 -0800

csiph-web