Unicode work

This commit is contained in:
Tim Bentley 2009-07-10 16:41:08 +01:00
parent 93655bc92e
commit 2aaf72bb20

View File

@ -19,6 +19,7 @@ import os
import os.path import os.path
import logging import logging
import chardet import chardet
import codecs
from openlp.plugins.bibles.lib.bibleDBimpl import BibleDBImpl from openlp.plugins.bibles.lib.bibleDBimpl import BibleDBImpl
from openlp.core.lib import Receiver from openlp.core.lib import Receiver
from PyQt4 import QtCore from PyQt4 import QtCore
@ -49,7 +50,7 @@ class BibleOSISImpl():
self.loadbible = False self.loadbible = False
def load_data(self, osisfile_record, dialogobject=None): def load_data(self, osisfile_record, dialogobject=None):
osis = open(osisfile_record, u'r') osis = codecs.open(osisfile_record, u'r')
book_ptr = None book_ptr = None
id = 0 id = 0
count = 0 count = 0
@ -59,8 +60,6 @@ class BibleOSISImpl():
# cancel pressed on UI # cancel pressed on UI
if self.loadbible == False: if self.loadbible == False:
break break
details = chardet.detect(file_record)
file_record = unicode(file_record, details['encoding'])
pos = file_record.find(verseText) pos = file_record.find(verseText)
if pos > -1: # we have a verse if pos > -1: # we have a verse
epos= file_record.find(u'>', pos) epos= file_record.find(u'>', pos)
@ -75,7 +74,6 @@ class BibleOSISImpl():
text = self.remove_block(u'<title', u'</title>', text) text = self.remove_block(u'<title', u'</title>', text)
text = self.remove_block(u'<note', u'</note>', text) text = self.remove_block(u'<note', u'</note>', text)
text = self.remove_block(u'<divineName', u'</divineName>', text) text = self.remove_block(u'<divineName', u'</divineName>', text)
text = self.remove_tag(u'<lb', text) text = self.remove_tag(u'<lb', text)
text = self.remove_tag(u'<q', text) text = self.remove_tag(u'<q', text)
text = self.remove_tag(u'<l', text) text = self.remove_tag(u'<l', text)