def xml_name(p, keep_escape=False, encoding=None):
 if isinstance(p, unicode):
  pass
 elif isinstance(p, str):
  if (sabnzbd.DARWIN or (encoding == 'utf-8')):
   p = p.decode('utf-8', 'replace')
  elif gUTF:
   p = p.decode('utf-8', 'replace')
  else:
   p = p.decode(codepage, 'replace')
 else:
  p = str(p)
 if keep_escape:
  return p.encode('ascii', 'xmlcharrefreplace')
 else:
  return escape(p).encode('ascii', 'xmlcharrefreplace')

def xml_name ( p , keep_escape = False , encoding = None ) : if isinstance ( p , unicode ) : pass elif isinstance ( p , str ) : if ( sabnzbd . DARWIN or ( encoding == 'utf-8' ) ) : p = p . decode ( 'utf-8' , 'replace' ) elif gUTF : p = p . decode ( 'utf-8' , 'replace' ) else : p = p . decode ( codepage , 'replace' ) else : p = str ( p ) if keep_escape : return p . encode ( 'ascii' , 'xmlcharrefreplace' ) else : return escape ( p ) . encode ( 'ascii' , 'xmlcharrefreplace' )
prepare name for use in html/xml contect .