error when printing a UTF-8 string (python 2.6.2)
Peter Otten
__peter__ at web.de
Wed Apr 21 09:29:33 EDT 2010
python at bdurham.com wrote:
> Are you saying all open() calls in Python that read text files,
> automatically convert UTF-8 content to Unicode in the same manner as the
> following might when using Python 2.6?
>
> codecs.open( fileName, mode='r', encoding='UTF8', ... )
That's what I meant to say, but it's not actually true.
Quoting http://docs.python.org/py3k/library/functions.html#open
"""
open(file, mode='r', buffering=None, encoding=None, errors=None,
newline=None, closefd=True)
[...]
encoding is the name of the encoding used to decode or encode the file. This
should only be used in text mode. The default encoding is platform dependent
(whatever locale.getpreferredencoding() returns), but any encoding supported
by Python can be used. See the codecs module for the list of supported
encodings.
"""
So it just happend to be UTF-8 on my machine.
Peter
More information about the Python-list
mailing list