Search code examples
xmlluaxml-serializationlua-tableluaxml

Luaxml (lua 5.3 compatible CTAN version) error unicode.utf8.char


I try to convert lua tables into string to store in a file/database and vice versa. LuaXML seems the right tool for that.

I tried to use the original, lua 5.1 compatible, luaXML but I had numerous errors due to the fact that I use lua 5.3. There seems to be a new version, lua 5.3 compatible, on the CTAN repository. However, I have a

/usr/local/share/lua/5.3/luaxml-entities.lua:2: attempt to index a nil value (global 'unicode')

This is due to unicode.utf8.char which seems to be a dependency of luatex unicode library.

Can we substitute some function of the lua 5.3 unicode library instead to avoid the luatex dependency ? Alternatively, how shall I "integrate" the luatex resources in a stand alone lua interpreter (ZeroBrane) ?


Solution

  • I went around the error by substituting line 2 of the luaxml-entities.lua (part of the luaXML folder) from :

    local char unicode.utf8.char
    

    with :

    local char = utf8.char
    

    or also (will take unicode if it is present, utf8 if not)

    local char = unicode and unicode.utf8.char or utf8.char
    

    So far, I had no side effect by doing any of those modifications.