Changeset - 8e76649f11ad
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 14 years ago 2011-09-29 21:55:32
marcin@python-works.com
fixes safe_str method
- trye directly to encode with given encoding instead of trying to make a string out of the unicode
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/__init__.py
Show inline comments
 
@@ -177,7 +177,7 @@ def safe_unicode(str_, from_encoding='ut
 
    except UnicodeDecodeError:
 
        pass
 
    
 
    try:
 
    try:        
 
        import chardet
 
        encoding = chardet.detect(str_)['encoding']
 
        if encoding is None:
 
@@ -203,7 +203,7 @@ def safe_str(unicode_, to_encoding='utf8
 
        return unicode_
 

	
 
    try:
 
        return str(unicode_)
 
        return unicode_.encode(to_encoding)
 
    except UnicodeEncodeError:
 
        pass
 
    
0 comments (0 inline, 0 general)