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