MCPcopy Index your code
hub / github.com/clips/pattern / encode_basestring

Function encode_basestring

pattern/web/json/encoder.py:36–44  ·  view source on GitHub ↗

Return a JSON representation of a Python string

(s)

Source from the content-addressed store, hash-verified

34FLOAT_REPR = repr
35
36def encode_basestring(s):
37 """Return a JSON representation of a Python string
38
39 """
40 if isinstance(s, str) and HAS_UTF8.search(s) is not None:
41 s = s.decode('utf-8')
42 def replace(match):
43 return ESCAPE_DCT[match.group(0)]
44 return u'"' + ESCAPE.sub(replace, s) + u'"'
45
46
47def py_encode_basestring_ascii(s):

Callers 1

encodeMethod · 0.85

Calls 2

searchMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…