The code is rather long, but I can give some crucial points :
I extract the editor text with
Code:
data=current_container.raw_data(file, decode=True, normalize_to_nfc=True)
Then apply the search on it :
Code:
pattern = regex.compile(unicode(search['find']), flags)
match = pattern.search(data)
I have no error, except if I replace ‘ or \u2018 with \xE2\x80\x98
Tell me if you want more.