changeset 1494:8e76649f11ad beta

fixes safe_str method - trye directly to encode with given encoding instead of trying to make a string out of the unicode
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 29 Sep 2011 22:55:32 +0300
parents 5a3252dd7fd9
children 5bd42279930c
files rhodecode/lib/__init__.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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