aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libbe/util/encoding.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/libbe/util/encoding.py b/libbe/util/encoding.py
index 22a2e30..3fde8cb 100644
--- a/libbe/util/encoding.py
+++ b/libbe/util/encoding.py
@@ -41,19 +41,22 @@ def get_encoding():
if ENCODING != None:
return ENCODING
encoding = locale.getpreferredencoding() or sys.getdefaultencoding()
- if sys.platform != 'win32' or sys.version_info[:2] > (2, 3):
- encoding = locale.getlocale(locale.LC_TIME)[1] or encoding
- # Python 2.3 on windows doesn't know about 'XYZ' alias for 'cpXYZ'
return encoding
def get_input_encoding():
- return get_encoding()
+ return sys.__stdin__.encoding or get_encoding()
def get_output_encoding():
return sys.__stdout__.encoding or get_encoding()
def get_filesystem_encoding():
- return get_encoding()
+ """Return the encoding that should be used for file contents
+
+ Note that `sys.getfilesystemencoding` returns the prefered
+ encoding for file *names*, and we're assuming that this is also
+ the prefered encoding for their contents.
+ """
+ return sys.getfilesystemencoding() or get_encoding()
def get_argv_encoding():
return get_encoding()