#NEWLINE# def decode_utf8( string ) : #NEWLINE# #INDENT# ' Returns the given string as a unicode string (if possible).\n    ' #NEWLINE# if isinstance ( string , str ) : #NEWLINE# #INDENT# for encoding in ( ( 'utf-8' , ) , ( 'windows-1252' , ) , ( 'utf-8' , 'ignore' ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return string . decode ( * encoding ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# return string #NEWLINE# #UNINDENT# return unicode ( string )