Skip to content

Commit

Permalink
Fixing #10 (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
0ki authored and timofurrer committed Sep 27, 2018
1 parent 7a01398 commit c90c436
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions colorful/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def style_string(string, ansi_style, colormode, nested=False):
# replace nest placeholders with the current begin style
if PY2:
if isinstance(string, str):
string = string.decode(DEFAULT_ENCODE)
string = string.decode('utf-8' if DEFAULT_ENCODE is None else DEFAULT_ENCODE)
string = UNICODE(string).replace(ansi.NEST_PLACEHOLDER, ansi_start_code)

return '{start_code}{string}{end_code}{nest_ph}'.format(
Expand All @@ -232,7 +232,7 @@ def __unicode__(self):
return self.styled_string

def __str__(self):
return self.styled_string.encode(DEFAULT_ENCODE)
return self.styled_string.encode('utf-8' if DEFAULT_ENCODE is None else DEFAULT_ENCODE)
else:
def __str__(self):
return self.styled_string
Expand Down

0 comments on commit c90c436

Please sign in to comment.