Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Python and UTF-8 text encoding on OSX' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Python and UTF-8 text encoding on OSX
Authored by: JohnRoth1 on Jul 23, '10 04:50:35PM

The line at the top of the script only affects the encoding for unicode literals in the source - it has no effect whatever at run time.

This isn't a bug, and it isn't "fixed" in any release. The issue is that if you read something from a file and want to convert it to unicode, the Python run-time needs to know the encoding of the input, because there are literally dozens of possibilities. There are a lot of ways of doing that, from the poster's suggestion through a parameter on the open function and methods on the str and unicode objects. However, it does have to be done explicitly; the run-time takes the safe choice and defaults to 7-bit ASCII.

John Roth



[ Reply to This | # ]