Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jayfoad opened this issue Oct 25, 2018 · 1 comment
Open

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

jayfoad opened this issue Oct 25, 2018 · 1 comment

Comments

@jayfoad
Copy link
Contributor

jayfoad commented Oct 25, 2018

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
Copy link
Contributor Author

jayfoad commented Feb 6, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant