dyalog-jupyter-kernel
dyalog-jupyter-kernel copied to clipboard
Kernel doesn't work in non-UTF-8 locales
If you run the kernel in a non-UTF-8 locale, e.g. by setting LANG=C, it (sometimes) fails to output APL characters with an error message like: 'ascii' codec can't encode characters in position 39-55: ordinal not in range(128)
The usual advice is to fix your locale or override it, e.g. with one of:
LANG=C.UTF-8 # force UTF-8 locale
PYTHONIOENCODING=UTF-8 # tell Python to use UTF-8 for io streams
PYTHONIOENCODING=:replace # tell Python to replace characters it can't encode with '?'
PYTHONUTF8=1 # tell Python to use UTF-8 for io streams
Alternatively we could try to fix the troublesome print statement with something like:
e = locale.getpreferredencoding(False)
print(s.encode(e, 'replace').decode(e))
But I'm not sure if it's worth it.