how to make format operator % work with unicode as expected

Peter Pei yantao at telus.com
Sun Jan 27 00:37:48 EST 2008


I just sorted posts by from, and figured out that you are kind of PSF guy... 
However that does not make you qualified, I care whether you are capable not 
whether you have the time to spend for PSF.

Adios!
==========================================
"Peter Pei" <yantao at telus.com> wrote in message 
news:YHUmj.43649$fj2.28192 at edtnps82...
> 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.
> ==============================================================
>
> "Steven D'Aprano" <steve at REMOVE-THIS-cybersource.com.au> wrote in message 
> news:13po55nc0q0s06 at corp.supernews.com...
>> On Sun, 27 Jan 2008 04:06:45 +0000, Peter Pei wrote:
>>
>>> I probably should mention that what I want is to make all parts of the
>>> string aligned, and look like table. I am not looking for other ways to
>>> make it table-alike, but only interested in making % work with unicode
>>> -counting characters not bytes...
>>
>> % already works with unicode. Just give it unicode arguments:
>>
>>
>>>>> print u"x y z %s 1 2 3" % u"Les misérables"
>> x y z Les misérables 1 2 3
>>
>>
>> -- 
>> Steven
> 




More information about the Python-list mailing list