From e9c8ffe5e9d0665ec9dbc1e6d0253196d812f678 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 16 Jun 2016 21:06:03 +0530 Subject: [PATCH] ... --- src/calibre/utils/terminal.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/utils/terminal.py b/src/calibre/utils/terminal.py index a86d9874aa..ebe79bc10c 100644 --- a/src/calibre/utils/terminal.py +++ b/src/calibre/utils/terminal.py @@ -146,6 +146,8 @@ class Detect(object): while text: t, text = text[:chunk], text[chunk:] wt = c_wchar_p(t) + # Use the fact that len(t) == wcslen(wt) in python 2.7 on + # windows where the python unicode type uses UTF-16 if not self.write_console(self.file_handle, wt, len(t), byref(written), None): # Older versions of windows can fail to write large strings # to console with WriteConsoleW (seen it happen on Win XP)