Encoding UTF-8 instead of PDFDoc

Koki Nomura <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <CAE6MiFY5U-LyEd0hVSoxFrD1HRo_7HHhSd2_OSFUjFbNoo-CnQ@mail.gmail.com>
Hi,

pdfdocEnc() in pdfdoc.py raises a UnicodeEncodeError as below when I
process a PDF file with Unicode characters. I'm running my script on Python
3.6.0.

UnicodeEncodeError: 'charmap' codec can't encode character '\x00' in
position 11: character maps to <undefined>

This error disappears when I change the encoding from extpdfdoc to utf-8 in
this block of code.

if isPy3:
    def pdfdocEnc(x):
        return x.encode('extpdfdoc') if isinstance(x,str) else x

While I don't fully understand 'extpdfdoc' encoding, can we change this
encoding to utf-8 as PDF specifications allow to use Unicode as well as
PDFDocEncoding?

Thanks,
Koki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.