View Single Post
Old 10-09-2014, 07:01 AM   #1022
tkeo
Connoisseur
tkeo began at the beginning.
 
Posts: 94
Karma: 10
Join Date: Feb 2014
Location: Japan
Device: Kindle PaperWhite, Kobo Aura HD
Hi Kevin,

Quote:
1. in compatibility_utils.py, under Windows, you can not use the following code, as it will break almost on Windows machines that do not use the cp you use.

+
+ # Conversion of argv to unicode without using cdll.kernel32.GetCommandLineW
+ FILE_SYSTEM_ENCODING = sys.getfilesystemencoding()
+ uargv = []
+ in_double_quotations = False
+ for arg in sys.argv:
+ if not isinstance(arg, unicode):
+ arg = arg.decode(FILE_SYSTEM_ENCODING)
+ if in_double_quotations:
+ if arg[-1] == u'"':
+ in_double_quotations = False
+ arg = arg[:-1]
+ uargv[-1] = uargv[-1] + u' ' + arg
+ else:
+ if arg[0] == u'"':
+ arg = arg[1:]
+ if arg[-1] == u'"':
+ arg = arg[:-1]
+ else:
+ in_double_quotations = True
+ uargv.append(arg)
+ return uargv
+

It is much better to use the kernel32 call, and kindleunpack.py has always used this routine (see utf8_utils.py for utf8_argv) in one form or another. It is needed for full unicode (at least utf-16) compliance on all Windows machines under python 2.
This is for debug purpose code.
Since in my IDE (spyder), parameters are not able to passed by kernel32 call.
Could you keep it in until the end of this debug?

Thanks,
tkeo is offline   Reply With Quote