From df3896d585d3ded35a5a7d3ecfa5956744694a78 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 7 Apr 2012 19:22:02 +0530 Subject: [PATCH] ... --- src/calibre/constants.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/calibre/constants.py b/src/calibre/constants.py index d5663d31f1..db6f54ce00 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -48,6 +48,18 @@ fcntl = None if iswindows else importlib.import_module('fcntl') filesystem_encoding = sys.getfilesystemencoding() if filesystem_encoding is None: filesystem_encoding = 'utf-8' +else: + try: + if codecs.lookup(filesystem_encoding).name == 'ascii': + filesystem_encoding = 'utf-8' + # On linux, unicode arguments to os file functions are coerced to an ascii + # bytestring if sys.getfilesystemencoding() == 'ascii', which is + # just plain dumb. So issue a warning. + print ('WARNING: You do not have the LANG environment variable set. ' + 'This will cause problems with non-ascii filenames. ' + 'Set it to something like en_US.UTF-8.\n') + except: + filesystem_encoding = 'utf-8' DEBUG = False