Only encode if necessary
This commit is contained in:
parent
7fb3c3c04c
commit
bd775d0d40
|
@ -126,6 +126,7 @@ def get_line_length(line, encoding="UTF-8"):
|
||||||
if line.count("{!") != line.count("!}"):
|
if line.count("{!") != line.count("!}"):
|
||||||
raise BadColorString("Number of {! is not equal to number of !}")
|
raise BadColorString("Number of {! is not equal to number of !}")
|
||||||
|
|
||||||
|
if isinstance(line, unicode):
|
||||||
line = line.encode(encoding, "replace")
|
line = line.encode(encoding, "replace")
|
||||||
|
|
||||||
# Remove all the color tags
|
# Remove all the color tags
|
||||||
|
@ -146,6 +147,7 @@ def parse_color_string(s, encoding="UTF-8"):
|
||||||
if s.count("{!") != s.count("!}"):
|
if s.count("{!") != s.count("!}"):
|
||||||
raise BadColorString("Number of {! is not equal to number of !}")
|
raise BadColorString("Number of {! is not equal to number of !}")
|
||||||
|
|
||||||
|
if isinstance(s, unicode):
|
||||||
s = s.encode(encoding, "replace")
|
s = s.encode(encoding, "replace")
|
||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
|
|
Loading…
Reference in New Issue