PDF Output: Fix incorrect encoding for some chinese characters in the PDF Outline (Table of Contents). Fixes #1416222 [Incorrect TOC entries in PDF files converted from Chinese EPUB file](https://bugs.launchpad.net/calibre/+bug/1416222)

This commit is contained in:
Kovid Goyal 2015-01-31 00:08:01 +05:30
parent 9e7d1a6ed4
commit 2a32abf933

View File

@ -128,8 +128,7 @@ class String(unicode):
class UTF16String(unicode):
def pdf_serialize(self, stream):
s = self.replace('\\', '\\\\')
raw = codecs.BOM_UTF16_BE + s.encode('utf-16-be')
raw = codecs.BOM_UTF16_BE + self.encode('utf-16-be').replace(b'\\', b'\\\\')
stream.write(b'('+escape_unbalanced_parantheses(raw)+b')')
class Dictionary(dict):