On 20/01/2010 23:46, MRAB wrote:
Martin v. Löwis wrote:
The only supported default encodings in Python are:
Python 2.x: ASCII
Python 3.x: UTF-8
Is this true?
For 3.x: yes. However, the default encoding is much less relevant in
3.x, since Python will never implicitly use the default encoding, except
when some C module asks for a char*. In particular, ordering between
bytes and unicodes causes a type error always.
I thought the default encoding in Python 3 was platform
specific (i.e. cp1252 on Windows).
Not at all. You are confusing this with the IO encoding of text
files, which indeed defaults to the locale encoding (and CP_ACP
on Windows specifically - which may or may not be cp1252).
The default encoding (i.e. the one you could theoretically set
with sys.setdefaultencoding) in 3.x is UTF-8.
It's UTF-8 precisely to avoid cross-platform encoding problems,
especially important now that 'normal' strings are Unicode.
Where the default *file system encoding* is used (i.e. text files are
written or read without specifying an encoding) then there are still
cross-platform issues. As I said, a file written on one platform may be
unreadable on another platform.
The default encoding is only used for encoding strings to bytes when an
encoding is not specified. I'm not sure when that can happen in Python
3? (Most streams will have an encoding and is the default encoding used
in preference to the stream encoding?)
Michael
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
READ CAREFULLY. By accepting and reading this email you agree, on behalf of
your employer, to release me from all obligations and waivers arising from any
and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap,
clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and
acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your
employer, its partners, licensors, agents and assigns, in perpetuity, without
prejudice to my ongoing rights and privileges. You further represent that you
have the authority to release me from any BOGUS AGREEMENTS on behalf of your
employer.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com