Skip to content

Commit 651074e

Browse files
feat: optional stdout decoding (#351)
Do not decode stdout if the bytes cannot be represented as UTF-8. Refs: #350 Co-authored-by: Jessica Tegner <jessica.tegner@outlook.com>
1 parent c28366d commit 651074e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pypandoc/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,8 @@ def _convert_input(source, format, input_type, to, extra_args=(),
450450
raise RuntimeError('Pandoc died with exitcode "%s" during conversion.' % (p.returncode))
451451

452452
try:
453-
stdout = stdout.decode('utf-8')
453+
if not (to in ["odt", "docx", "epub", "epub3", "pdf"] and outputfile == "-"):
454+
stdout = stdout.decode('utf-8')
454455
except UnicodeDecodeError:
455456
# this shouldn't happen: pandoc more or less guarantees that the output is utf-8!
456457
raise RuntimeError('Pandoc output was not utf-8.')

0 commit comments

Comments
 (0)