--- a/createrepo/utils.py +++ b/createrepo/utils.py @@ -76,29 +76,11 @@ def returnFD(filename): def utf8String(string): """hands back a unicoded string""" if string is None: - return '' + return u'' elif isinstance(string, unicode): return string - try: - x = unicode(string, 'ascii') - return string - except UnicodeError: - encodings = ['utf-8', 'iso-8859-1', 'iso-8859-15', 'iso-8859-2'] - for enc in encodings: - try: - x = unicode(string, enc) - except UnicodeError: - pass - else: - if x.encode(enc) == string: - return x.encode('utf-8') - newstring = '' - for char in string: - if ord(char) > 127: - newstring = newstring + '?' - else: - newstring = newstring + char - return newstring + else: + return unicode(string, 'utf-8', errors='replace') def checkAndMakeDir(dir): """