how to make format operator % work with unicode as expected

Peter Pei yantao at telus.com
Sun Jan 27 10:57:37 EST 2008


"Steven D'Aprano" <steve at REMOVE-THIS-cybersource.com.au> wrote in message 
news:13pode8n39n8ea8 at corp.supernews.com...
> On Sun, 27 Jan 2008 05:32:40 +0000, Peter Pei wrote:
>
>> You didn't understand my question, but thanks any way.
>>
>> Yes, it is true that %s already support unicode, and I did not
>> contradict that. But it counts the number of bytes instead of
>> characters, and makes things like %-20s out of alignment. If you don't
>> understand my assertion, please don't argue back and I am only
>> interested in answers from those who are qualified.
>
> I understand your assertion. I think it is nonsense.
this kind of reply only embarrase yourself
>
>>>> def test():
> ...     print "12345678901234567890 +"
> ...     print "%-20s +" % "Plain ASCII"
> ...     print u"%-20s +" % u"Les misérables-\320\321\322"
> ...
>>>> test()
> 12345678901234567890 +
> Plain ASCII          +
> Les misérables-ÐÑÒ   +
>
>
>
>
> -- 
> Steven 




More information about the Python-list mailing list