#NEWLINE# def _GetUtf8Contents( self , file_name ) : #NEWLINE# #INDENT# 'Check for errors in file_name and return a string for csv reader.' #NEWLINE# contents = self . _FileContents ( file_name ) #NEWLINE# if ( not contents ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( ( len ( contents ) >= 2 ) and ( contents [ 0 : 2 ] in ( codecs . BOM_UTF16_BE , codecs . BOM_UTF16_LE ) ) ) : #NEWLINE# #INDENT# self . _problems . FileFormat ( 'appears to be encoded in utf-16' , ( file_name , ) ) #NEWLINE# contents = codecs . getdecoder ( 'utf-16' ) ( contents ) [ 0 ] . encode ( 'utf-8' ) #NEWLINE# #UNINDENT# null_index = contents . find ( '\x00' ) #NEWLINE# if ( null_index != ( - 1 ) ) : #NEWLINE# #INDENT# m = re . search ( '.{,20}\\0.{,20}' , contents , re . DOTALL ) #NEWLINE# self . _problems . FileFormat ( ( 'contains a null in text "%s" at byte %d' % ( codecs . getencoder ( 'string_escape' ) ( m . group ( ) ) , ( null_index + 1 ) ) ) , ( file_name , ) ) #NEWLINE# return #NEWLINE# #UNINDENT# contents = contents . lstrip ( codecs . BOM_UTF8 ) #NEWLINE# return contents