Staging
v0.8.1
https://foss.heptapod.net/mercurial/hgview
Revision 4403e4c1f3f4c0112982d7471e12b0c8fb2f959c authored by David Douard on 05 June 2009, 15:21:27 UTC, committed by David Douard on 05 June 2009, 15:21:27 UTC
1 parent 5b541e2
Raw File
Tip revision: 4403e4c1f3f4c0112982d7471e12b0c8fb2f959c authored by David Douard on 05 June 2009, 15:21:27 UTC
fix a regression (direct call to FileDiffViewer using "hg qv myfile" was broken)
Tip revision: 4403e4c
util.py
# -*- coding: utf-8 -*-
# util functions
#
# Copyright (C) 2009 Logilab. All rights reserved.
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.

def tounicode(s):
    """
    Tries to convert s into a unicode string
    """
    for encoding in ('utf-8', 'iso-8859-15', 'cp1252'):
        try:
            return unicode(s, encoding)
        except UnicodeDecodeError:
            pass
    return unicode(s, 'utf-8', 'replace')
        
        
    
back to top