before you reduce a strig, make it unicode object

This commit is contained in:
Nikos Kouremenos 2006-09-28 14:30:12 +00:00
parent 33c346b75c
commit 9a05650bc6
1 changed files with 7 additions and 4 deletions

View File

@ -175,10 +175,13 @@ def reduce_chars_newlines(text, max_chars = 0, max_lines = 0):
If any of the params is not present (None or 0) the action
on it is not performed'''
def _cut_if_long(str):
if len(str) > max_chars:
str = str[:max_chars - 3] + '...'
return str
def _cut_if_long(string):
if len(string) > max_chars:
string = string[:max_chars - 3] + '...'
return string
if isinstance(text, str):
text = text.decode('utf-8')
if max_lines == 0:
lines = text.split('\n')