Skip to content

Commit 42a253a

Browse files
committed
Add can_encode
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent 16b091a commit 42a253a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

bpython/config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ def getpreferredencoding():
2121
return locale.getpreferredencoding() or sys.getdefaultencoding()
2222

2323

24-
def supports_box_chars():
25-
"""Check if the encoding suppors Unicode box characters."""
24+
def can_encode(c):
2625
try:
27-
for c in (u'│', u'│', u'─', u'─', u'└', u'┘', u'┌', u'┐'):
28-
c.encode(getpreferredencoding())
26+
c.encode(getpreferredencoding())
2927
return True
3028
except UnicodeEncodeError:
3129
return False
3230

31+
def supports_box_chars():
32+
"""Check if the encoding suppors Unicode box characters."""
33+
return all(map( can_encode, u'│─└┘┌┐'))
3334

3435
def get_config_home():
3536
"""Returns the base directory for bpython's configuration files."""

0 commit comments

Comments
 (0)