# HG changeset patch # User Marcin Kuzminski # Date 1317326132 -10800 # Node ID 8e76649f11adc07a7f20facfaf0812002ec2dcc0 # Parent 5a3252dd7fd9270a7c2b6e0d62a634e2086e9f71 fixes safe_str method - trye directly to encode with given encoding instead of trying to make a string out of the unicode diff -r 5a3252dd7fd9 -r 8e76649f11ad rhodecode/lib/__init__.py --- a/rhodecode/lib/__init__.py Thu Sep 29 03:38:45 2011 +0300 +++ b/rhodecode/lib/__init__.py Thu Sep 29 22:55:32 2011 +0300 @@ -177,7 +177,7 @@ except UnicodeDecodeError: pass - try: + try: import chardet encoding = chardet.detect(str_)['encoding'] if encoding is None: @@ -203,7 +203,7 @@ return unicode_ try: - return str(unicode_) + return unicode_.encode(to_encoding) except UnicodeEncodeError: pass