before you reduce a strig, make it unicode object
This commit is contained in:
		
							parent
							
								
									33c346b75c
								
							
						
					
					
						commit
						9a05650bc6
					
				
					 1 changed files with 7 additions and 4 deletions
				
			
		| 
						 | 
					@ -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
 | 
						If any of the params is not present (None or 0) the action
 | 
				
			||||||
	on it is not performed'''
 | 
						on it is not performed'''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def _cut_if_long(str):
 | 
						def _cut_if_long(string):
 | 
				
			||||||
		if len(str) > max_chars:
 | 
							if len(string) > max_chars:
 | 
				
			||||||
			str = str[:max_chars - 3] + '...'
 | 
								string = string[:max_chars - 3] + '...'
 | 
				
			||||||
		return str
 | 
							return string
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						if isinstance(text, str):
 | 
				
			||||||
 | 
							text = text.decode('utf-8')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if max_lines == 0:
 | 
						if max_lines == 0:
 | 
				
			||||||
		lines = text.split('\n')
 | 
							lines = text.split('\n')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue