Did I find the right examples for you? yes no

All Samples(5)  |  Call(4)  |  Derive(0)  |  Import(1)
A strange attempt at celaning up unicode.

        def u_clean(s):
    """A strange attempt at celaning up unicode."""
    uni = ''
        # Try this first
        uni = str(s).decode('iso-8859-1')
    except UnicodeDecodeError:
            # Try utf-8 next
            uni = str(s).decode('utf-8')
        except UnicodeError:
            # Last resort method... one chracter at a time
            if s and type(s) in (str, unicode):
                for c in s:
                        uni += unicodedata.normalize('NFKC', unicode(c))
                    except UnicodeDecodeError:
                        uni += '-'
    return uni.encode('ascii', 'xmlcharrefreplace')

src/d/e/denigma-HEAD/denigma/apps/track/views.py   denigma(Download)
from models import Visitor
from utils import u_clean as uc
                    'id': v.id,
                    #'user': uc(v.user),
                    'user_agent': uc(v.user_agent),
                    'referrer': uc(v.referrer),
                    'url': uc(v.url),

src/d/e/denigma-HEAD/denigma/apps/track/middleware.py   denigma(Download)
        one_hour_ago = now - timedelta(hours=1)
        if not visitor.last_update or visitor.last_update <= one_hour_ago:
            visitor.referrer = utils.u_clean(request.META.get('HTTP_REFERER', 'unknown')[:255])
            # Reset the number of pages they've been to