[luatex] luatex problem with file with umlauts on windows 10
Reinhard Kotucha
reinhard.kotucha at web.de
Sun Apr 26 19:12:16 CEST 2020
On 2020-04-26 at 17:12:08 +0200, Ulrike Fischer wrote:
> Am Sun, 26 Apr 2020 11:00:50 +0100 schrieb Philip Taylor:
>
> > Trying to understand why Akira-san had written :
> >
> >>
> >> local function is_texlive ()
> >> local a = kpse.var_value ('command_line_encoding')
> >> if a
> >> then
> >> return true
> >> else
> >> return false
> >> end
> >> end
> >
> > rather than
> >
> >> local function is_texlive ()
> >> local a = kpse.var_value ('command_line_encoding')
> >> return a
> >> end
> >
>
> because a is = "utf-8" and not "true" in texlive.
But Lua treats everything as true in boolean expressions which is not
false or nil. Thus one could even write
local function is_texlive ()
return kpse.var_value ('command_line_encoding')
end
is_texlive () returns either a string (true) or nil (false). I
suppose that kpathsea returns nil if the variable
command_line_encoding is not defined.
BTW, unless you have to distinguish between nil and false something
like
else return false
is not necessary. You could also write
else return nil
which has the same effect as omitting the return statement completely.
> Try
>
> \directlua{ local a = kpse.var_value ('command_line_encoding')
> print(a)}
Better force a into a boolean context. One possibility is double
negation:
$ lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> print(type(a))
nil
> print (not not a)
false
> a = 'hello'
> print(type(a))
string
> print (not not a)
true
> os.exit()
Regards,
Reinhard
--
------------------------------------------------------------------
Reinhard Kotucha Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover mailto:reinhard.kotucha at web.de
------------------------------------------------------------------
More information about the luatex
mailing list.