From 67d93b84d69d093da5b62dc6546b624d281f77ec Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 20 Apr 2012 14:22:42 +0530 Subject: [PATCH] ... --- 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 d369e36b9d..4e83791962 100644 --- a/src/calibre/ebooks/mobi/writer8/skeleton.py +++ b/src/calibre/ebooks/mobi/writer8/skeleton.py @@ -59,13 +59,14 @@ def tostring(raw, **kwargs): manually replace all hex entities with their unicode codepoints. ''' xml_declaration = kwargs.pop('xml_declaration', False) + encoding = kwargs.pop('encoding', 'UTF-8') kwargs['encoding'] = unicode kwargs['xml_declaration'] = False ans = etree.tostring(raw, **kwargs) if xml_declaration: - ans = '\n' + ans + ans = '\n'%encoding + ans return re.sub(r'&#x([0-9A-Fa-f]+);', lambda m:mychr(int(m.group(1), 16)), - ans).encode('utf-8') + ans).encode(encoding) class Chunk(object):