self-hosting repo available
Lele Gaifax
lele at nautilus.homeip.net
Mon Apr 11 10:41:27 BST 2005
>>>>> "Erik" == Erik Bågfors <zindar at gmail.com> writes:
Erik> Thanks lele. You are right. It gives me ascii. Should
Erik> python take this from locale? It's all UTF-8 there?
Erik> : [bagfors at zyrgelkwytng]$ ; locale LANG=sv_SE.UTF-8
As said, this depends on the system setup for Python. You didn't
mention which distro you're using, but you should be able to locate
either an /etc/python/site.py or an equivalent somewhere under the
/usr/lib/python2.3/ tree.
It should contain a call to sys.setdefaultencoding(). Debian does it
this way:
encoding = "ascii" # Default value set by _PyUnicode_Init()
if 1: ## <------- THIS is 0 by default
# Enable to support locale aware default string encodings.
import locale
loc = locale.getdefaultlocale()
if loc[1]:
encoding = loc[1]
if 0:
# Enable to switch off string to Unicode coercion and implicit
# Unicode to string conversion.
encoding = "undefined"
if encoding != "ascii":
# On Non-Unicode builds this will raise an AttributeError...
sys.setdefaultencoding(encoding) # Needs Python Unicode build !
ciao, lele.
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
email: lele at seldati.it | -- Fortunato Depero, 1929.
More information about the bazaar
mailing list