Problem with format string and unicode

Discussion in 'Python' started by Hans Martin, Mar 28, 2008.

  1. Hans Martin

    Hans Martin Guest

    Hi,

    this is probably a trivial problem, but a google search for "python"
    and "unicode" and" format string" gives too many hits: If I specify
    e.g. "%20s" in a format string and the string value contains UTF-8
    stuff (differing number of bytes per character), the length of the
    resulting string (in characters) varies. How can I fix this?

    Many thanks in advance!

    --
    Psssst! Schon vom neuen GMX MultiMessenger gehört?
    Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
     
    Hans Martin, Mar 28, 2008
    #1
    1. Advertising

  2. On Fri, 28 Mar 2008 21:13:00 +0100, Hans Martin wrote:

    > this is probably a trivial problem, but a google search for "python"
    > and "unicode" and" format string" gives too many hits: If I specify
    > e.g. "%20s" in a format string and the string value contains UTF-8
    > stuff (differing number of bytes per character), the length of the
    > resulting string (in characters) varies. How can I fix this?


    Use unicode strings instead.

    Ciao,
    Marc 'BlackJack' Rintsch
     
    Marc 'BlackJack' Rintsch, Mar 28, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gabriele *darkbard* Farina

    Unicode digit to unicode string

    Gabriele *darkbard* Farina, May 16, 2006, in forum: Python
    Replies:
    2
    Views:
    530
    Gabriele *darkbard* Farina
    May 16, 2006
  2. Chirag Mistry
    Replies:
    6
    Views:
    176
    Ollivier Robert
    Feb 8, 2008
  3. Chris Angelico
    Replies:
    3
    Views:
    160
    Mark Lawrence
    Mar 1, 2013
  4. Peter Otten
    Replies:
    0
    Views:
    138
    Peter Otten
    Feb 28, 2013
  5. Rick Johnson
    Replies:
    0
    Views:
    146
    Rick Johnson
    Feb 28, 2013
Loading...

Share This Page