def py_scanstring(s, end, encoding=None, strict=True,<EOL>_b=BACKSLASH, _m=STRINGCHUNK.match):
if encoding is None:<EOL><INDENT>encoding = DEFAULT_ENCODING<EOL><DEDENT>chunks = []<EOL>_append = chunks.append<EOL>begin = end - <NUM_LIT:1><EOL>while <NUM_LIT:1>:<EOL><INDENT>chunk = _m(s, end)<EOL>if chunk is None:<EOL><INDENT>raise ValueError(<EOL>errmsg("<STR_LIT>", s, begin))<EOL><DEDENT>end = chunk.end()<EOL>content, terminator = chunk.groups()<EOL>if content:<EOL><INDENT>if not isinstance(content, unicode):<EOL><INDENT>content = unicode(content, encoding)<EOL><DEDENT>_append(content)<EOL><DEDENT>if terminator == '<STR_LIT:">':<EOL><INDENT>break<EOL><DEDENT>elif terminator != '<STR_LIT:\\>':<EOL><INDENT>if strict:<EOL><INDENT>msg = "<STR_LIT>" % (terminator,)<EOL>raise ValueError(errmsg(msg, s, end))<EOL><DEDENT>else:<EOL><INDENT>_append(terminator)<EOL>continue<EOL><DEDENT><DEDENT>try:<EOL><INDENT>esc = s[end]<EOL><DEDENT>except IndexError:<EOL><INDENT>raise ValueError(<EOL>errmsg("<STR_LIT>", s, begin))<EOL><DEDENT>if esc != '<STR_LIT:u>':<EOL><INDENT>try:<EOL><INDENT>char = _b[esc]<EOL><DEDENT>except KeyError:<EOL><INDENT>msg = "<STR_LIT>" + repr(esc)<EOL>raise ValueError(errmsg(msg, s, end))<EOL><DEDENT>end += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>uni = _decode_uXXXX(s, end)<EOL>end += <NUM_LIT:5><EOL>if sys.maxunicode > <NUM_LIT> and<NUM_LIT> <= uni <= <NUM_LIT> and s[end:end + <NUM_LIT:2>] == '<STR_LIT>':<EOL><INDENT>uni2 = _decode_uXXXX(s, end + <NUM_LIT:1>)<EOL>if <NUM_LIT> <= uni2 <= <NUM_LIT>:<EOL><INDENT>uni = <NUM_LIT> + (((uni - <NUM_LIT>) << <NUM_LIT:10>) | (uni2 - <NUM_LIT>))<EOL>end += <NUM_LIT:6><EOL><DEDENT><DEDENT>char = unichr(uni)<EOL><DEDENT>_append(char)<EOL><DEDENT>return u'<STR_LIT>'.join(chunks), end<EOL>
Scan the string s for a JSON string. End is the index of the
    character in s after the quote that started the JSON string.
    Unescapes all valid JSON string escape sequences and raises ValueError
    on attempt to decode an invalid string. If strict is False then literal
    control characters are allowed in the string.

    Returns a tuple of the decoded string and the index of the character in s
    after the end quote.