pdfa: codecs.encode -> hexlify (simpler)

This commit is contained in:
James R. Barlow
2018-03-29 22:17:23 -07:00
parent 81c3f780d4
commit b36df9cf9e
+2 -2
View File
@@ -18,7 +18,7 @@
# Generate a PDFA_def.ps file for Ghostscript >= 9.14
from string import Template
import codecs
from binascii import hexlify
import pkg_resources
import PyPDF2 as pypdf
@@ -93,7 +93,7 @@ def encode_text_string(s: str) -> str:
return ''
utf16_bytes = s.encode('utf-16be')
ascii_hex_bytes = codecs.encode(b'\xfe\xff' + utf16_bytes, 'hex')
ascii_hex_bytes = hexlify(b'\xfe\xff' + utf16_bytes)
ascii_hex_str = ascii_hex_bytes.decode('ascii').lower()
return ascii_hex_str