On 22/01/2010 14:18, Karen Tracey wrote:
On Fri, Jan 22, 2010 at 7:38 AM, Michael Foord
<[email protected] <mailto:[email protected]>> wrote:
On 21/01/2010 21:21, "Martin v. Löwis" wrote:
Where the default *file system encoding* is used (i.e.
text files are
written or read without specifying an encoding)
I think you misunderstand the notion of the *file system
encoding*.
It is *not* a "file encoding", but the file *system* encoding,
i.e.
the encoding for file *names*, not for file *content*.
It was used on Windows for Windows 95; it is not used anymore
on Windows
(although it's still used on Unix).
Ok, I'm just using the wrong terminology. I'm aware that mbcs is
used for filename encoding on Windows (right?). The encoding I'm
talking about is the encoding that Python uses to decode a file
(or encode a string) when you do the following in Python 3:
text = open(filename).read()
open(filename, 'w').write(some_string)
It isn't the default encoding (always utf-8 by default in Python 3
apparently), it isn't the file system encoding which is the system
encoding used for file names. What is the correct terminology for
this platform dependent encoding that Python uses here?
The doc here:
http://docs.python.org/3.1/library/functions.html?highlight=open#open
just calls it default encoding and clarifies that is "whatever
locale.getpreferredencoding() returns".
Heh, so we have two different encoding mechanisms both called "default
encoding". One is always utf-8 in Python 3 and one is platform
dependent... Great. :-)
Michael
The important point is that it is platform dependent - so if you
ship and use text files with your Python application and don't
specify an encoding then it will work fine on some platforms and
blow up or use the wrong encoding on other platforms.
Yes. If you ship text files with your Python application, then you'd
best take care to know the encoding when you create them and specify
it as the encoding to use when you open the file for reading by your
application.
Karen
_______________________________________________
Python-Dev mailing list
[email protected]
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
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com