make check for unicode text as argument

This commit is contained in:
Dimitur Kirov 2005-08-17 14:38:20 +00:00
parent 7c9ea41c1b
commit f9657d7521
1 changed files with 4 additions and 0 deletions

View File

@ -86,6 +86,10 @@ def reduce_chars_newlines(text, max_chars = 0, max_lines = 0,
If any of the params is not present(None or 0) the action If any of the params is not present(None or 0) the action
on it is not performed on it is not performed
''' '''
# assure that we have only unicode text
if type(text) == str:
text = unicode(text, encoding='utf-8')
def _cut_if_long(str): def _cut_if_long(str):
if len(str) > max_chars: if len(str) > max_chars:
str = str[:max_chars - 3] + '...' str = str[:max_chars - 3] + '...'