![‘utf-8’编解码器无法解码字节 0xd0](https://linux22.com/image/440671/%E2%80%98utf-8%E2%80%99%E7%BC%96%E8%A7%A3%E7%A0%81%E5%99%A8%E6%97%A0%E6%B3%95%E8%A7%A3%E7%A0%81%E5%AD%97%E8%8A%82%200xd0.png)
我在 Ubuntu 20.04 上使用 tex-live 尝试编译包含保加利亚语文本的文件时收到以下错误。我使用 kile 进行编译。
Traceback (most recent call last):
File "/usr/bin/texliveonfly", line 360, in <module>
(output, returnCode) = compileTex()
File "/usr/bin/texliveonfly", line 277, in compileTexDoc
return readFromProcess(process)
File "/usr/bin/texliveonfly", line 292, in readFromProcess
line = getProcessLine()
File "/usr/bin/texliveonfly", line 285, in <lambda>
getProcessLine = lambda : frombytesifpy3(process.stdout.readline())
File "/usr/bin/texliveonfly", line 44, in <lambda>
frombytesifpy3 = lambda b = None : b.decode("UTF-8") if py3 and b != None else b
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 19: invalid continuation byte
最小示例:
\documentclass[a4paper]{report}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english, bulgarian]{babel}
\begin{document}
\begin{enumerate}
\item {\em Решение.} Тази стъпка използва компресираната и
факторизирана матрица от коефициенти на системата и дясната страна,
за намиране на решението. Изчислителната сложност на тази стъпка
е $O(rn)$.
\end{enumerate}
\end{document}
如果我在 \item 行和下一行之间添加一个空行,它会进行编译,但这会添加一个不需要的新段落,并且在实际文件中我还有其他代码也会破坏它。
即如果我按如下所示更改 \item,它将突然开始编译:
...
\begin{enumerate}
\item {\em Решение.} Тази стъпка използва компресираната и
факторизирана матрица от коефициенти на системата и дясната страна,
за намиране на решението. Изчислителната сложност на тази стъпка
е $O(rn)$.
\end{enumerate}
...
我在使用 tex-live 的 Ubuntu 20.04.3 LTS 上,刚刚从 18.04 升级。在另一台装有 Ubuntu 20.04 的计算机上,相同的文本作为更大文件的一部分进行编译,没有任何问题。
编译命令的完整输出日志:
*****
***** PDFLaTeX output:
***** cd "/home/iict/Documents/test_not_working"
***** texliveonfly -a -interaction=nonstopmode not_working.tex
*****
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./not_working.tex
LaTeX2e <2020-02-02> patch level 2
L3 programming layer <2020-02-14>
(/usr/share/texlive/texmf-dist/tex/latex/base/report.cls
Document Class: report 2019/12/20 v1.4l Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/cyrillic/t2aenc.def
(/usr/share/texlive/texmf-dist/tex/latex/base/t2aenc.dfu)))
(/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty)
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.sty
(/usr/share/texlive/texmf-dist/tex/generic/babel/switch.def)
(/usr/share/texlive/texmf-dist/tex/generic/babel-english/english.ldf
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.def
(/usr/share/texlive/texmf-dist/tex/generic/babel/txtbabel.def)))
(/usr/share/texlive/texmf-dist/tex/generic/babel-bulgarian/bulgarian.ldf))
(/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def)
(./not_working.aux (/usr/share/texlive/texmf-dist/tex/latex/cyrillic/t2acmr.fd)
)
Overfull \hbox (0.53506pt too wide) in paragraph at lines 9--13
Traceback (most recent call last):
File "/usr/bin/texliveonfly", line 360, in <module>
(output, returnCode) = compileTex()
File "/usr/bin/texliveonfly", line 277, in compileTexDoc
return readFromProcess(process)
File "/usr/bin/texliveonfly", line 292, in readFromProcess
line = getProcessLine()
File "/usr/bin/texliveonfly", line 285, in <lambda>
getProcessLine = lambda : frombytesifpy3(process.stdout.readline())
File "/usr/bin/texliveonfly", line 44, in <lambda>
frombytesifpy3 = lambda b = None : b.decode("UTF-8") if py3 and b != None else b
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 19: invalid continuation byte
答案1
该错误看起来像是 python 错误,因此尝试不使用 texliveonfly,直接使用 pdflatex。