From d3fa7cd6ee05db6ff75a9e39ad338b3fb19b7475 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 17 Oct 2010 14:46:28 -0600 Subject: [PATCH] Fix #6964 (ebook-convert: problems with conversion in Mac OS X, If the file or folder name contains Cyrillic characters) --- src/calibre/startup.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/calibre/startup.py b/src/calibre/startup.py index b5741c1991..e384153993 100644 --- a/src/calibre/startup.py +++ b/src/calibre/startup.py @@ -16,7 +16,7 @@ __builtin__.__dict__['_'] = lambda s: s # immediately translated to the environment language __builtin__.__dict__['__'] = lambda s: s -from calibre.constants import iswindows, preferred_encoding, plugins +from calibre.constants import iswindows, preferred_encoding, plugins, isosx _run_once = False winutil = winutilerror = None @@ -35,9 +35,17 @@ if not _run_once: ################################################################################ # Convert command line arguments to unicode + enc = preferred_encoding + if isosx: + # Newer versions of OS X seem to use UTF-8 + try: + [x.decode('utf-8') for x in sys.argv[1:]] + enc = 'utf-8' + except: + pass for i in range(1, len(sys.argv)): if not isinstance(sys.argv[i], unicode): - sys.argv[i] = sys.argv[i].decode(preferred_encoding, 'replace') + sys.argv[i] = sys.argv[i].decode(enc, 'replace') ################################################################################ # Setup resources