'Returns the info[\'name\'] field as Unicode string.
@return Unicode string.'

def get_name_as_unicode(self):

    if (not self.metainfo_valid):
        raise TorrentDefNotFinalizedException()
    if ('name.utf-8' in self.metainfo['info']):
        try:
            return unicode(self.metainfo['info']['name.utf-8'], 'UTF-8')
        except UnicodeError:
            pass
    if ('name' in self.metainfo['info']):
        if ('encoding' in self.metainfo):
            try:
                return unicode(self.metainfo['info']['name'], self.metainfo['encoding'])
            except UnicodeError:
                pass
            except LookupError:
                pass
        try:
            return unicode(self.metainfo['info']['name'])
        except UnicodeError:
            pass
        try:
            return unicode(self.metainfo['info']['name'], 'UTF-8')
        except UnicodeError:
            pass
        try:
            def filter_characters(name):
                def filter_character(char):
                    if (0 < ord(char) < 128):
                        return char
                    else:
                        self._logger.debug('Bad    character    filter    %s,    isalnum?    %s', ord(char), char.isalnum())
                        return u'?'
                return u''.join([filter_character(char) for char in name])
            return unicode(filter_characters(self.metainfo['info']['name']))
        except UnicodeError:
            pass
    return u''
