gpt4 book ai didi

encoding - unoconv 与 --stdin 不起作用

转载 作者:行者123 更新时间:2023-12-01 10:23:24 26 4
gpt4 key购买 nike

我正在使用 unoconv转换 docxpdf .只要我通过文件名传递文档,一切都很好:

$ unoconv -f pdf --stdout test.docx

但是一旦我使用 --stdin它不再起作用:
$ unoconv -f pdf --stdin --stdout < test.docx

Traceback (most recent call last):
File "/usr/bin/unoconv", line 1275, in <module>
main()
File "/usr/bin/unoconv", line 1185, in main
inputfn = sys.stdin.read()
File "/usr/lib/python3.5/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xad in position 41: invalid start byte

这是同一个文件。为什么这不起作用?

这是文件: https://nofile.io/f/bKz1zWf745K/test.docx

最佳答案

我认为问题在于--stdin选项不会做人们可能认为它会做的事情。

在错误消息中,第 1185 行中的变量名称看起来很可疑:

inputfn = sys.stdin.read()

事实上,检查 source code ,似乎从 STDIN 读取的文本被解释为文件名,而不是文件内容。

但是,文档( man unoconv )具有误导性:

--stdin
Read input file from stdin (filenames are ignored if provided)



这听起来真的不像将输入解释为文件名。

我建议你 file a bug report关于这个(也许首先检查是否已经有一个)。

关于encoding - unoconv 与 --stdin 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48950720/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com