如何找到“无效的 UTF-8 字节或序列,位于第 ... 行”这一行?

如何找到“无效的 UTF-8 字节或序列,位于第 ... 行”这一行?

在我的 report.log 中我有很多这样的消息:

(/usr/share/texlive/texmf-dist/tex/generic/xstring/xstring.sty
(/usr/share/texlive/texmf-dist/tex/generic/xstring/xstring.tex
\integerpart=\count405
Invalid UTF-8 byte or sequence at line 35 replaced by U+FFFD.
\decimalpart=\count406
Invalid UTF-8 byte or sequence at line 79 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 79 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 83 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 86 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 102 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 114 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 120 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 125 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 147 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 147 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 147 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 182 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 182 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 182 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 183 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 184 replaced by U+FFFD.

不幸的是,提到的行号与我的文件中的内容不对应report.tex。我该如何正确定位这些错误?

这是我的.latexmkrc

system ("mkdir -p build/figures");

@default_files = ('report.tex');
@cus_dep_list = (@cus_dep_list, "glo gls 0 makenomenclature");
sub makenomenclature {
   system("makeindex $_[0].glo -s nomencl.ist -o $_[0].gls"); }
@generated_exts = (@generated_exts, 'glo');

# Custom dependency and function for nomencl package
  add_cus_dep( 'nlo', 'nls', 0, 'makenlo2nls' );
  sub makenlo2nls {
  system( "makeindex -s nomencl.ist -o \"$_[0].nls\" \"$_[0].nlo\"" );
}

$out_dir = 'build';
$pdflatex = 'xelatex --synctex=1 -interaction=nonstopmode -shell-escape';
$latex = 'latex --synctex=1 -interaction=nonstopmode -shell-escape';

答案1

查看日志片段

(/usr/share/texlive/texmf-dist/tex/generic/xstring/xstring.sty
(/usr/share/texlive/texmf-dist/tex/generic/xstring/xstring.tex
\integerpart=\count405
Invalid UTF-8 byte or sequence at line 35 replaced by U+FFFD.

您会看到(xstring.sty打开,然后 (xstring.tex打开,因为错误消息中没有任何行号与当前打开的文件堆栈上的最新文件)有关 。xstring.tex

该文件确实有非 ascii 注释,但在其当前版本中(至少在 texlive 2022 中)它被正确编码为 UTF-8 并开始:

% !TeX encoding = UTF-8
% Ce fichier contient le code de l'extension "xstring"
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                    %
\def\xstringname               {xstring}                             %
\def\xstringversion              {1.84}                              %
%                                                                    %
\def\xstringdate              {2021/07/21}                           %

第 35 行中第一个错误是:

\newcount\decimalpart% compteurs utilisés par xstring

在注释中使用 UTF-8 e-acute

相关内容