(raw)
Returns a Unicode object on success, or None on failure
Returns a Unicode object on success, or None on failure
Returns a Unicode object on success or None on failure
def decode_utf8(raw):
    """
    Returns a Unicode object on success, or None on failure
    """
    try:
        raw = codecs.decode(raw,'utf-8', 'replace')
        #extracts BOM if exists
        raw = raw.encode('utf8')
        if raw.startswith(codecs.BOM_UTF8):
            raw = raw.replace(codecs.BOM_UTF8, '', 1)
        return raw.decode('utf-8')
    except:
       return None
def decode_utf8 ( raw ) : try : raw = codecs . decode ( raw , 'utf-8' , 'replace' ) #extracts BOM if exists raw = raw . encode ( 'utf8' ) if raw . startswith ( codecs . BOM_UTF8 ) : raw = raw . replace ( codecs . BOM_UTF8 , '' , 1 ) return raw . decode ( 'utf-8' ) except : return None