From 64adf22ac0883bb7d56a1985f9452e3c0e51e018 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 4 Dec 2019 23:16:30 +0530 Subject: [PATCH] Fix azw3 conversion of entities failing on narrow python builds such as windows --- src/calibre/ebooks/mobi/writer8/skeleton.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/mobi/writer8/skeleton.py b/src/calibre/ebooks/mobi/writer8/skeleton.py index 8fbdedece8..1fab295273 100644 --- a/src/calibre/ebooks/mobi/writer8/skeleton.py +++ b/src/calibre/ebooks/mobi/writer8/skeleton.py @@ -13,9 +13,10 @@ from xml.sax.saxutils import escape from lxml import etree +from calibre import my_unichr from calibre.ebooks.oeb.base import XHTML_NS, extract from calibre.ebooks.mobi.utils import to_base, PolyglotDict -from polyglot.builtins import iteritems, unicode_type, codepoint_to_chr as mychr +from polyglot.builtins import iteritems, unicode_type CHUNK_SIZE = 8192 @@ -73,7 +74,7 @@ def tostring(raw, **kwargs): ans = etree.tostring(raw, **kwargs) if xml_declaration: ans = '\n'%encoding + ans - return re.sub(r'&#x([0-9A-Fa-f]+);', lambda m:mychr(int(m.group(1), 16)), + return re.sub(r'&#x([0-9A-Fa-f]+);', lambda m:my_unichr(int(m.group(1), 16)), ans).encode(encoding)