Hi,

on a Linux system and python 2.5.1 I have the
following behaviour which I do not understand:



case 1
> python -c 'a="ä"; print a ; print a.center(6,"-") ; b=unicode(a, "utf8"); 
> print b.center(6,"-")'
ä
--ä--
--ä---
>


case 2
----- an UnicodeEncodeError in this case:
> python -c 'a="ä"; print a ; print a.center(20,"-") ; b=unicode(a, "utf8"); 
> print b.center(20,"-")' | cat
Traceback (most recent call last):
  File "<string>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 9: 
ordinal not in range(128)
ä
--ä--
>


The behaviour changes if I pipe the output to another prog or to a file.
and
centering with the string a is not correct, but with string b.



Could somebody please explain this to me?




Thanks in advance
-- 
Kurt Müller, m...@problemlos.ch

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to