Sorry to bother everyone again - this is a followup question to my earlier question:
Can openout handle a filename with spaces?
(I suppose I can combine this with the earlier question, but this seems to be a "gotcha" of the original question.) While I have a solution there, it breaks when using filenames with umlauts and when using either latin1/utf8 input encodings. The MWE gets an additional line (to break it):
\usepackage[latin1]{inputenc}
or
\usepackage[utf8]{inputenc}
The errors are different for each case. Since it works without the inputenc package, I'm very tempted to say, "just remove this line and see what happens."
I looked around and found the following question (which seemed most pertinant):
The discussion there seems to say that inputenc will change the umlaut character to a tex macro. So ö becomes \"o etc.
My question is, does this expansion break the code that handles the asterisk/space replacement below? If so, then do I need to expand/replace the \scantokens macro with a loop that checks for this extra condition? yuck!
MWE:
% "test öffnen.tex"
% Variations in run command to illustrate a more specific requirement ...
% Without {inputenc}
% Works: >h:\MikTeX\MikTeX.2.9p\texmf\miktex\bin\pdflatex "test öffnen.tex"
% Works: >h:\MikTeX\MikTeX.2.9p\texmf\miktex\bin\pdflatex "-job-name=test oeffnen" "test öffnen.tex"
% Works: >h:\MikTeX\MikTeX.2.9p\texmf\miktex\bin\pdflatex "-job-name=test öffnen" "test öffnen.tex"
% BROKEN with \usepackage[latin1]{inputenc}
% BROKEN with \usepackage[utf8]{inputenc}
% >h:\MikTeX\MikTeX.2.9p\texmf\miktex\bin\pdflatex "-job-name=test öffnen" "test öffnen.tex"
% Same run-command as above, different package
\pdfoutput=1
\documentclass[german]{article}
\usepackage[a4paper]{geometry}
\usepackage{babel}
\usepackage[T1]{fontenc}
%%%\usepackage[latin1]{inputenc}
%%% jobname=test*öffnen
%%% ! TeX capacity exceeded, sorry [input stack size=5000].
%%% \font@name ->
%%% \T1/cmr/m/n/10
%%% l.27 ...scantokens\expandafter{\JobnameX\noexpand}
%%% }
%%% If you really absolutely need more capacity,
%%% you can ask a wizard to enlarge me.
%%%\usepackage[utf8]{inputenc}
%%% produces error on console: pdflatex: Windows API error 1113: No mapping for the Unicode character exists in the target multi-byte code page.
\typeout{jobname=\jobname}
% Convert jobname
\edef\JobnameX{\jobname}
\catcode`\*=\active
\def*{ }
\edef\JobnameX{\scantokens\expandafter{\JobnameX\noexpand}}
\catcode`\*=12 %
\newcommand{\TestFilename}{\JobnameX .ips}
\typeout{TestFilename=\TestFilename}
%%%
%%%
\begin{document}
%%% Write stuff to output - then read it back into a pdfobj
\newwrite\MyFilehandle
\immediate\openout\MyFilehandle="\TestFilename"
\typeout{Test writing stuff to output file=\TestFilename}
\immediate\write\MyFilehandle{Test writing stuff to output file=\TestFilename}
\immediate\closeout\MyFilehandle
\immediate\pdfobj file {\TestFilename} %%% Just to show a snapshot of the entire process.
%%% FYI - we embed papertray/bursting/external page requirement commands for postprocessing
%%% (actually written as a 'pagepiece' dictionary)
%%%
%%% Write some text to create a pdf
Write some text into the pdf.
\end{document}
\endinput
The error when using latin1 says I should expand TeXs stack. Which I guess I could do - only I'm not convinced that that is the problem. It seems more like a symptom.
*chars but now uses the same quoting approach as TeX Live does. – Joseph Wright Mar 03 '15 at 18:21("C:\ . . ._test_miktex29\20150728\stack_exchange\mwe ä test.tex"
- There is a funny Symbol following the umlaut, (which gets capitalized) does the update handle latin chars in the file name?
– infowanna Jul 31 '15 at 06:48