def clean_unicode(comment_str): comment_str = comment_str.replace('\n', '').replace('\r', '').strip() comment_str = ' '.join(comment_str.split()) return UnicodeDammit(comment_str).unicode_markup