'This method was added to fix:
GtkWarning: gtk_text_buffer_emit_insert: assertion `g_utf8_validate (text, len, NULL)\'
:param text: A text that may or may not be in UTF-8.
:return: A text, that\'s in UTF-8, and can be printed in a text view'

def _to_utf8(self, text):

    text = repr(text)
    text = text[1:(-1)]
    for special_char in ['\n', '\r', ' DCTB ']:
        text = text.replace(repr(special_char)[1:(-1)], special_char)
    text = text.replace("\\'", "'")
    text = text.replace('\\\\"', '\\"')
    return text
