Add a check for Unicode support.

This makes poezio refuse to run if the environment is known broken.
This commit is contained in:
Emmanuel Gil Peyrot 2018-06-07 14:42:14 +02:00
parent 0319ce5079
commit e846825fc8
2 changed files with 19 additions and 2 deletions

View file

@ -1,7 +1,7 @@
def run():
from poezio.poezio import main, test_curses, test_env
from poezio.poezio import main, test_curses, test_env, test_unicode
if not test_curses() or not test_env():
if not test_curses() or not test_env() or not test_unicode():
import sys
sys.exit(1)
else:

View file

@ -53,6 +53,23 @@ def test_env():
return True
def test_unicode():
import poopt
try:
poopt.wcswidth('')
except UnicodeError:
print("""\
ERROR: The current system is misconfigured for Unicode.
Check your locale setup, especially the $LANG environment variable and \
whether it matches a locale built on your system. Also check that it is a \
.UTF-8 locale, and not using some legacy encoding.
Poezio is unable to display characters properly, so it will now exit.""")
return False
return True
def main():
"""
Entry point.