def _encode_basestring_ascii(s):
 try:
  if (isinstance(s, str) and (HAS_UTF8.search(s) is not None)):
   s = s.decode('utf-8')
 except:
  pass
 def replace(match):
  s = match.group(0)
  try:
   return ESCAPE_DCT[s]
  except KeyError:
   n = ord(s)
   if (n < 65536):
    return ('\\u%04x' % (n,))
   else:
    n -= 65536
    s1 = (55296 | ((n >> 10) & 1023))
    s2 = (56320 | (n & 1023))
    return ('\\u%04x\\u%04x' % (s1, s2))
 return (('"' + str(ESCAPE_ASCII.sub(replace, s))) + '"')

def _encode_basestring_ascii ( s ) : try : if ( isinstance ( s , str ) and ( HAS_UTF8 . search ( s ) is not None ) ) : s = s . decode ( 'utf-8' ) except : pass def replace ( match ) : s = match . group ( 0 ) try : return ESCAPE_DCT [ s ] except KeyError : n = ord ( s ) if ( n < 65536 ) : return ( '\\u%04x' % ( n , ) ) else : n -= 65536 s1 = ( 55296 | ( ( n >> 10 ) & 1023 ) ) s2 = ( 56320 | ( n & 1023 ) ) return ( '\\u%04x\\u%04x' % ( s1 , s2 ) ) return ( ( '"' + str ( ESCAPE_ASCII . sub ( replace , s ) ) ) + '"' )
return an ascii-only json representation of a python string .