![将西里尔文文本写入文件](https://linux22.com/image/391350/%E5%B0%86%E8%A5%BF%E9%87%8C%E5%B0%94%E6%96%87%E6%96%87%E6%9C%AC%E5%86%99%E5%85%A5%E6%96%87%E4%BB%B6.png)
你能解释一下发生了什么事吗?
我正在使用最新的 MiKTeX 2.9.6960 64 位版本(昨天刚刚安装)。
我正在尝试在不使用 inputenc 包的情况下将一些西里尔文文本写入单独的文件:
\documentclass{article}
\begin{document}
\newwrite\testwrite
\immediate\openout\testwrite=testwrite.txt
\immediate\write\testwrite{Ббббббббббббб}
\immediate\closeout\testwrite
\end{document}
但是 LaTeX 并没有告诉我编码有问题,而是告诉我它的一些内部命令未定义。以下是相应日志文件的一部分:
! Undefined control sequence.
\GenericError ...
#4 \errhelp \@err@ ...
l.9 \immediate\write\testwrite{Ббббббббббббб}
?
! Undefined control sequence.
\GenericError ...
\let \@err@ ...
l.9 \immediate\write\testwrite{Ббббббббббббб}
?
! Undefined control sequence.
\GenericError ...
\@empty \def \MessageBreak...
l.9 \immediate\write\testwrite{Ббббббббббббб}
?
! Undefined control sequence.
\GenericError ...
\endgroup
l.9 \immediate\write\testwrite{Ббббббббббббб}
?
! Undefined control sequence.
\GenericError ...
#4 \errhelp \@err@ ...
l.9 \immediate\write\testwrite{Ббббббббббббб}
?
! Undefined control sequence.
\GenericError ...
\let \@err@ ...
l.9 \immediate\write\testwrite{Ббббббббббббб}
?
! Undefined control sequence.
\GenericError ...
\@empty \def \MessageBreak...
l.9 \immediate\write\testwrite{Ббббббббббббб}
等等。
这是一个错误还是发生了什么事情?
感谢您的回答。
答案1
活动字符设置为扩展为排版指令(或显示字符未设置的错误消息),您只需逐字逐句地写下文本即可:
\documentclass{article}
\begin{document}
\newwrite\testwrite
\immediate\openout\testwrite=testwrite.txt
\immediate\write\testwrite{\detokenize{Ббббббббббббб}}
\immediate\closeout\testwrite
\end{document}
答案2
如果你不想使用 inputenc,请添加\UseRawInputEncoding
\UseRawInputEncoding
\documentclass{article}
\begin{document}
\newwrite\testwrite
\immediate\openout\testwrite=testwrite.txt
\immediate\write\testwrite{Ббббббббббббб}
\immediate\closeout\testwrite
\end{document}