[luatex] string.char

Heiko Oberdiek heiko.oberdiek at googlemail.com
Mon Apr 4 20:33:34 CEST 2011


On Mon, Apr 04, 2011 at 06:32:58PM +0200, Paul Isambert wrote:

> Le 04/04/2011 18:14, Heiko Oberdiek a écrit :
> >Hello,
> >
> >I have some obscure problem with string.char:
> >
> >% luatex -ini
> >\catcode`\{=1
> >\catcode`\}=2
> >\newlinechar=-1
> >
> >\directlua{tex.settoks(0, string.char(65, 0, 66))}
> >\message{\the\toks0}
> >
> >\csname @@end\endcsname\end
> >
> >
> >As result I expect "A^^@B", but I get "A^^@^^@".
> >All bytes after the first zero are ^^@ (zero byte).
> >
> >Tested with luatex 0.60.2 and 0.65.0.
> 
> No answer, but an additional observation: LuaTeX 0.66 (rev. 4087)
> with your code complains about an invalid UTF-8 sequence and then
> prints "A^^@" followed by some gibberish. But if I simply add
> another 65 before the 0, then it doesn't complain, but prints
> AA^^@^^@. That smells like bug.

Further addition:
  \message{\directlua{tex.print(string.char(65, 0, 66))}}
works, but
  \directlua{tex.settoks(0, "A\string\000B")}
has the wrong result "A^^@^^X", thus I conclude that
tex.settoks might be the problem.

Yours sincerely
  Heiko Oberdiek


More information about the luatex mailing list