def ascii(str):
 if (type(str) != type('')):
  return map(ascii, str)
 rv = ''
 for c in str:
  if ((c in (' DCTB ', '\n', '\r')) or (' ' <= c < chr(127))):
   rv = (rv + c)
  else:
   rv = ((rv + '\\') + ('x%02.2x' % ord(c)))
 return rv

def ascii ( str ) : if ( type ( str ) != type ( '' ) ) : return map ( ascii , str ) rv = '' for c in str : if ( ( c in ( ' DCTB ' , '\n' , '\r' ) ) or ( ' ' <= c < chr ( 127 ) ) ) : rv = ( rv + c ) else : rv = ( ( rv + '\\' ) + ( 'x%02.2x' % ord ( c ) ) ) return rv
return a string with all non-ascii characters hex-encoded .