Skip to content

Commit aafd947

Browse files
author
Kevin McDonald
committed
Adds a hacky setting of the locale
1 parent 51e8721 commit aafd947

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

SoftLayer/CLI/core.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@
3434
if sys.stdout.isatty():
3535
DEFAULT_FORMAT = 'table'
3636

37+
# Attempt to set the locale for the user if the default encoding is
38+
# ascii. More information here:
39+
# http://click.pocoo.org/4/python3/#python-3-surrogate-handling
40+
import codecs
41+
import locale
42+
try:
43+
ENC = codecs.lookup(locale.getpreferredencoding()).name
44+
except Exception:
45+
ENC = 'ascii'
46+
47+
if ENC == 'ascii':
48+
try:
49+
locale.setlocale(locale.LC_ALL, 'C.UTF-8')
50+
except Exception:
51+
pass
52+
3753

3854
class CommandLoader(click.MultiCommand):
3955
"""Loads module for click."""

0 commit comments

Comments
 (0)