MOBI Metadata reader: Correctly handle non ASCII characters when reading embedded metadata. Fixes #4223 (trouble with charset)

This commit is contained in:
Kovid Goyal 2009-12-25 08:13:38 -07:00
parent b4216f7d81
commit 0ad8343cdc

View File

@ -435,7 +435,8 @@ class MobiReader(object):
open(os.path.splitext(htmlfile)[0] + '.ncx', 'wb').write(ncx) open(os.path.splitext(htmlfile)[0] + '.ncx', 'wb').write(ncx)
def read_embedded_metadata(self, root, elem, guide): def read_embedded_metadata(self, root, elem, guide):
raw = '<package>' + html.tostring(elem, encoding='utf-8') + '</package>' raw = '<?xml version="1.0" encoding="utf-8" ?>\n<package>' + \
html.tostring(elem, encoding='utf-8') + '</package>'
stream = cStringIO.StringIO(raw) stream = cStringIO.StringIO(raw)
opf = OPF(stream) opf = OPF(stream)
self.embedded_mi = MetaInformation(opf) self.embedded_mi = MetaInformation(opf)