[I18n-sig] Format strings

Josef Spillner 2005 at kuarepoti-dju.net
Fri Nov 25 19:45:15 CET 2005


El Viernes, 25. Noviembre 2005 19:14, escribió:
> I don't see the relationship to Python in that posting...

The following should demonstrate it:

# -*- coding: utf-8 -*-
print "'%2s'" % "a"
print "'%2s'" % "á"
print "'%2s'" % u"á"

In the second case, while the string literal is recognized as utf-8 (thus two 
bytes being one character in this case), it eats the two character format 
string alone and doesn't leave any space for the empty character.

Note that if the file encoding is not given, then it would display as 'á', 
which is correct under the circumstances.

But in general, I don't see why line two in the example above cannot be like 
line three. It is not intuitive to only have one character printed as opposed 
to the two that are requested from the format string.

Actually, a related question: why are string objects ASCII by default instead 
of the encoding specified at the beginning of the file? Are there any plans 
to merge the "unicode" string functionality into basic strings?

Josef


More information about the I18n-sig mailing list