I faced a problem when pdflatex launched from Emacs couldn't compile files whose name contained Russian characters. The same code worked on Linux, so I suspected that something is wrong with encoding of file name. OS: Windows XP, file system encoding is cp-1251, Emacs: 24.5.1.
I created 2 files:
- D:/Russia.tex
- D:/Россия.tex
Then I tried this:
;works fine, produces Russia.pdf
(shell-command "pdflatex D:/Russia.tex")
;doesn't work. TeX error: I can't find file `D:/Россия.tex'
(shell-command "pdflatex D:/Россия.tex")
Then I tried to convert the Russian name to cp-1251:
;This works, but hard-coded 'cp1251 is bad
(setq file-name (encode-coding-string "D:/Россия.tex" 'cp1251))
(shell-command (concat "pdflatex " file-name))
This code has 1 defect - the file system encoding is hard-coded. Encoding and I/O page says that there is a variable file-name-coding-system
--- "specifies the coding system to use for encoding file names". But it is nil
for me.
Also the fact that utf-8 code doesn't work is weird as the page says:
On Windows 2000 and later, Emacs by default uses Unicode APIs to pass file names to the OS, so the value of file-name-coding-system is largely ignored. Lisp applications that need to encode or decode file names on the Lisp level should use utf-8 coding-system when system-type is windows-nt; the conversion of UTF-8 encoded file names to the encoding appropriate for communicating with the OS is performed internally by Emacs.
Maybe this note about utf-8 is not applicable to shell-command
? How to get the encoding of the file system?
file-name-coding-system
tolatin-1
. Setting toutf-8
just doesn't works on Windows 10 here. And If I not set explicitly, doesn't works neither because I set the preference-coding system to utf-8 and seems that the emacs choose this encoding after that. My setup now was fixed by this partial file of my init scripts: github.com/ryukinix/dotfiles/blob/master/.emacs.d/personal/…