Changeset - abe75448253c
[Not reviewed]
Merge default
0 3 0
Marcin Kuzminski - 14 years ago 2012-02-26 17:09:28
marcin@python-works.com
merged beta into stable
1 file changed with 0 insertions and 3 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/__init__.py
Show inline comments
 
@@ -226,27 +226,24 @@ def safe_str(unicode_, to_encoding=None)
 

	
 
    In case of UnicodeEncodeError we try to return it with encoding detected
 
    by chardet library if it fails fallback to string with errors replaced
 

	
 
    :param unicode_: unicode to encode
 
    :rtype: str
 
    :returns: str object
 
    """
 
    
 
    if not isinstance(unicode_, basestring):
 
        return str(unicode_)
 

	
 
    if not isinstance(unicode_, basestring):
 
        return str(unicode_)
 

	
 
    if isinstance(unicode_, str):
 
        return unicode_
 

	
 
    if not to_encoding:
 
        import rhodecode
 
        DEFAULT_ENCODING = rhodecode.CONFIG.get('default_encoding','utf8')
 
        to_encoding = DEFAULT_ENCODING
 

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