def uts(s, encoding, errors):
 if (errors == 'utf-8'):
  try:
   return s.encode(encoding, 'strict')
  except UnicodeEncodeError:
   x = []
   for c in s:
    try:
     x.append(c.encode(encoding, 'strict'))
    except UnicodeEncodeError:
     x.append(c.encode('utf8'))
   return ''.join(x)
 else:
  return s.encode(encoding, errors)

def uts ( s , encoding , errors ) : if ( errors == 'utf-8' ) : try : return s . encode ( encoding , 'strict' ) except UnicodeEncodeError : x = [ ] for c in s : try : x . append ( c . encode ( encoding , 'strict' ) ) except UnicodeEncodeError : x . append ( c . encode ( 'utf8' ) ) return '' . join ( x ) else : return s . encode ( encoding , errors )
convert a unicode object to a string .