Forgot to write changing catcode of `%': \catcode`\%=12 \directlua{ function toutf16(str) ... } \catcode`\%=14 Also, there is a typo in previous email - missing `}' before calling \NEXT Best, Igor