6

Must LuaTeX's \readline use latin-1 encoding?

In the example below, I first store é in a file (well, and ^^J) which works well. Then I read it back in, using \readline and get two characters é (and ^^M). Then writing it back to a file yields those two characters (or rather, the bytes in their utf-8 encoding). I would like to be able to do the round-trip "reading a utf-8 file and writing it back" without modification (besides some end-line space trimming perhaps).

% Write some Unicode char to a file tmp.aux
\immediate\openout5=tmp.aux
\immediate\write5{é}
\immediate\closeout5
%
% Read it back in, _using \readline_
\openin6=tmp.aux
\readline6 to \foo
\closein6
%
\message{\foo}                   % => Ā© and a carriage return
%
% Write again: the file is different from tmp.aux.
\immediate\openout5=out.aux
\immediate\write5{\foo}
\immediate\closeout5
%
\csname bye\endcsname
\csname @@end\endcsname

Using \read instead of \readline avoids the encoding problem but tokenizes the lines, which I don't want to do.

  • For information. This odd behaviour of \readline causes a bug in my morewrites package. – Bruno Le Floch Jun 8 '14 at 20:28
  • In my files are always é. Only out.aux with an additional CR. Linux with de_DE.utf8 and luatex beta-0.79.1 – user2478 Jun 8 '14 at 20:36
  • With TL2014 all looks good here: I get the odd é with the TL2012 release of LuaTeX. – Joseph Wright Jun 8 '14 at 20:39
  • @josephWright so I guess the answer is "bug in LuaTeX, fixed in the newest available release" (well, not quite available yet)? – Bruno Le Floch Jun 8 '14 at 22:15
  • @BrunoLeFloch I guess so: TL2013 also gives a slightly odd result. I've not tested in MiKTeX, but it's likely to have the latest LuaTeX so is probably correct. – Joseph Wright Jun 9 '14 at 5:59
4

As described in the comments, this issue seems to be solved by using the most recent version of LuaTeX, which seems to treat encodings in the same way for \read and \readline.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.