diff --git a/openlp/plugins/songs/lib/cclifileimport.py b/openlp/plugins/songs/lib/cclifileimport.py index 3d08584d0..28c487a78 100644 --- a/openlp/plugins/songs/lib/cclifileimport.py +++ b/openlp/plugins/songs/lib/cclifileimport.py @@ -78,7 +78,20 @@ class CCLIFileImport(SongImport): details = chardet.detect(detect_content) detect_file.close() infile = codecs.open(filename, u'r', details['encoding']) - lines = infile.readlines() + try: + lines = infile.readlines() + infile.close() + except UnicodeDecodeError: + # First 2kB were not sufficient to detect file encoding. + # This time we read entire file. + detect_file = open(filename, u'r') + detect_content = detect_file.read() + details = chardet.detect(detect_content) + detect_file.close() + # We read the contents again. Should it be a try as well? + infile = codecs.open(filename, u'r', details['encoding']) + lines = infile.readlines() + infile.close() ext = os.path.splitext(filename)[1] if ext.lower() == u'.usr': log.info(u'SongSelect .usr format file found %s: ',