dyalog-jupyter-kernel icon indicating copy to clipboard operation
dyalog-jupyter-kernel copied to clipboard

Kernel doesn't work in non-UTF-8 locales

Open jayfoad opened this issue 7 years ago • 1 comments

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)

jayfoad avatar Oct 25 '18 15:10 jayfoad

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.

jayfoad avatar Feb 06 '19 11:02 jayfoad