in Source/Assets/AppCenterEditorExtensions/Editor/Scripts/AppCenterEditorSDK/SimpleJson.cs [794:886]
static string ParseString(char[] json, ref int index, ref bool success)
{
if (_parseStringBuilder == null)
_parseStringBuilder = new StringBuilder(BUILDER_INIT);
_parseStringBuilder.Length = 0;
EatWhitespace(json, ref index);
// "
char c = json[index++];
bool complete = false;
while (!complete)
{
if (index == json.Length)
break;
c = json[index++];
if (c == '"')
{
complete = true;
break;
}
else if (c == '\\')
{
if (index == json.Length)
break;
c = json[index++];
if (c == '"')
_parseStringBuilder.Append('"');
else if (c == '\\')
_parseStringBuilder.Append('\\');
else if (c == '/')
_parseStringBuilder.Append('/');
else if (c == 'b')
_parseStringBuilder.Append('\b');
else if (c == 'f')
_parseStringBuilder.Append('\f');
else if (c == 'n')
_parseStringBuilder.Append('\n');
else if (c == 'r')
_parseStringBuilder.Append('\r');
else if (c == 't')
_parseStringBuilder.Append('\t');
else if (c == 'u')
{
int remainingLength = json.Length - index;
if (remainingLength >= 4)
{
// parse the 32 bit hex into an integer codepoint
uint codePoint;
if (!(success = UInt32.TryParse(new string(json, index, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codePoint)))
return "";
// convert the integer codepoint to a unicode char and add to string
if (0xD800 <= codePoint && codePoint <= 0xDBFF) // if high surrogate
{
index += 4; // skip 4 chars
remainingLength = json.Length - index;
if (remainingLength >= 6)
{
uint lowCodePoint;
if (new string(json, index, 2) == "\\u" && UInt32.TryParse(new string(json, index + 2, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out lowCodePoint))
{
if (0xDC00 <= lowCodePoint && lowCodePoint <= 0xDFFF) // if low surrogate
{
_parseStringBuilder.Append((char)codePoint);
_parseStringBuilder.Append((char)lowCodePoint);
index += 6; // skip 6 chars
continue;
}
}
}
success = false; // invalid surrogate pair
return "";
}
_parseStringBuilder.Append(ConvertFromUtf32((int)codePoint));
// skip 4 chars
index += 4;
}
else
break;
}
}
else
_parseStringBuilder.Append(c);
}
if (!complete)
{
success = false;
return null;
}
return _parseStringBuilder.ToString();
}