Hi there, when user double clicks on QTextCursor in QTextEdit, I am looking for a way to get a string from that QTextCursor.

Qt Code:
  1. class ContactsView(QtGui.QTextEdit):
  2. def __init__(self, parent=None):
  3. QtGui.QTextEdit.__init__(self, parent)
  4. #some initialization
  5.  
  6. def insert(self, name):
  7. cursor = self.textCursor()
  8. path = "image/icons/Messenger_blue32.png"
  9. icon = QtGui.QPixmap(path)
  10. image = icon.toImage()
  11. cursor.insertImage(image)
  12. cursor.insertText(name)
  13. self.setTextCursor(cursor)
  14. self.ensureCursorVisible()
  15. end = "<br />"
  16. fragment = QtGui.QTextDocumentFragment.fromHtml(end)
  17. self.textCursor().insertFragment(fragment)
  18.  
  19. def mouseDoubleClickEvent(self,event):
  20. cursor = self.cursorForPosition(event.pos())
  21. BlockUnderCursor = 2
  22. cursor.select(BlockUnderCursor)
  23. name = cursor.selectedText()
  24. print name
To copy to clipboard, switch view to plain text mode 

and when I run this program, I am getting this run time error;

ContactsView.py", line 24, in mouseDoubleClickEvent
print name
UnicodeEncodeError: 'ascii' codec can't encode character u'\ufffc' in position 0: ordinal not in range(128)
I believe I am getting this error because there are more than strings in cursor.
all I am interested is that I want to get a string from TextCursor whenever it is double clicked.
Could anyone give me an advise? any inputs would be very appreciated.
thank you for consideration.

regards
Naoya