I have this code snippet of legacy code that (apparently) decodes UTF-8 double-encoded text back to regular UTF-8:
import codecs
import sys
s=codecs.open('doubleutf8.dat', 'r', 'utf-8').read()
sys.stdout.write(
s
.encode('raw_unicode_escape')
.decode('utf-8')
)
I need to translate it into Lua and imitate all the possible side effects of decoding (if any).
Limitations: I can use any of the available Lua modules to handle UTF-8, but preferably stable, with LuaRocks support. I will not use Lupa or another Lua-Python-bridge solution, and I will not call os.execute()to call Python.
source
share