From a7991917715742dcebb7d55172703e37ace313d9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 30 Jul 2014 09:35:40 +0530 Subject: [PATCH] Edit Book: Fix subsetting of fonts not working if the text contains non-BMP unicode characters. Fixes #1349856 [Error using "Subset all Fonts"](https://bugs.launchpad.net/calibre/+bug/1349856) --- src/calibre/ebooks/oeb/polish/stats.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/polish/stats.py b/src/calibre/ebooks/oeb/polish/stats.py index 948e6aa912..879e664b52 100644 --- a/src/calibre/ebooks/oeb/polish/stats.py +++ b/src/calibre/ebooks/oeb/polish/stats.py @@ -133,7 +133,9 @@ class Page(QWebPage): # {{{ return QString(val) def _pass_json_value_setter(self, value): - self.bridge_value = json.loads(unicode(value)) + # Qt WebKit in Qt 4.x adds extra null bytes to the end of the string + # if the JSON contains non-BMP characters + self.bridge_value = json.loads(unicode(value).rstrip('\0')) _pass_json_value = pyqtProperty(QString, fget=_pass_json_value_getter, fset=_pass_json_value_setter)