Expose luaparse encoding mode option to lua-in-js
When trying to execute the strings '▲' or '▼' (html entities ▲ and ▼), luaparse gives an encoding error. lua-in-js should provide the option to change from the default encoding mode.
My scripts have chinese characters in it. It also throw the same error to me as well. I think the problem is here...
src/parser.ts
encodingMode: 'x-user-defined'
Downgrading to 2.2.0 fixed it for me.
encodingMode: 'x-user-defined' was introduced in 2.2.1.
I should have probably used encodingMode: 'none', could you give it a try? If it works, a PR would be welcome.
https://github.com/teoxoy/lua-in-js/pull/24
Actually, encodingMode: 'none' is not correct since it always sets value to null, we could use the raw property but we'd have to reparse the string literal ourselves.
'pseudo-latin1' seems like the best choice, but characters outside of ISO/IEC 8859-1 need to be escaped (via \u{XXX}) either by lua-in-js or by user code.
This should also now be removed:
https://github.com/teoxoy/lua-in-js/blob/1165827c2e0dc95b3962a70e8a8c97a758fc5944/src/parser.ts#L224
Relevant: https://github.com/fstirlitz/luaparse/issues/68. Ideally luaparse would allow for a utf16 encoding, but I don't know what that would entail.