def string_escape(text):
 replacements = (('\\', '\\\\'), ("'", "\\'"), ('"', '\\"'), ('\n', '\\n'), ('\r', '\\r'), ('\x00', '\\x00'), ('\\ufeff', '\\ufeff'), ('\\u2028', '\\u2028'), ('\\u2029', '\\u2029'))
 for (orig, repl) in replacements:
  text = text.replace(orig, repl)
 return text

def string_escape ( text ) : replacements = ( ( '\\' , '\\\\' ) , ( "'" , "\\'" ) , ( '"' , '\\"' ) , ( '\n' , '\\n' ) , ( '\r' , '\\r' ) , ( '\x00' , '\\x00' ) , ( '\\ufeff' , '\\ufeff' ) , ( '\\u2028' , '\\u2028' ) , ( '\\u2029' , '\\u2029' ) ) for ( orig , repl ) in replacements : text = text . replace ( orig , repl ) return text
escape values special to javascript in strings .