Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ConsumeStringAndValidate()

bool System.Text.Json.Utf8JsonReader.ConsumeStringAndValidate ( ReadOnlySpan< byte > data,
int idx )
inlineprivate

Definition at line 930 of file Utf8JsonReader.cs.

931 {
933 long lineNumber = _lineNumber;
935 bool flag = false;
936 while (true)
937 {
938 if (idx < data.Length)
939 {
940 byte b = data[idx];
941 if (b == 34)
942 {
943 if (!flag)
944 {
945 break;
946 }
947 flag = false;
948 }
949 else if (b == 92)
950 {
951 flag = !flag;
952 }
953 else if (flag)
954 {
955 int num = JsonConstants.EscapableChars.IndexOf(b);
956 if (num == -1)
957 {
958 ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.InvalidCharacterAfterEscapeWithinString, b);
959 }
960 if (b == 117)
961 {
963 if (!ValidateHexDigits(data, idx + 1))
964 {
965 idx = data.Length;
966 goto IL_00e5;
967 }
968 idx += 4;
969 }
970 flag = false;
971 }
972 else if (b < 32)
973 {
974 ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.InvalidCharacterWithinString, b);
975 }
977 idx++;
978 continue;
979 }
980 goto IL_00e5;
981 IL_00e5:
982 if (idx < data.Length)
983 {
984 break;
985 }
986 if (IsLastSpan)
987 {
988 ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.EndOfStringNotFound, 0);
989 }
990 _lineNumber = lineNumber;
992 return false;
993 }
995 ValueSpan = data.Slice(0, idx);
996 _stringHasEscaping = true;
997 _tokenType = JsonTokenType.String;
998 _consumed += idx + 2;
999 return true;
1000 }
ReadOnlySpan< T > Slice(int start)
bool ValidateHexDigits(ReadOnlySpan< byte > data, int idx)

References System.Text.Json.Utf8JsonReader._bytePositionInLine, System.Text.Json.Utf8JsonReader._consumed, System.Text.Json.Utf8JsonReader._lineNumber, System.Text.Json.Utf8JsonReader._stringHasEscaping, System.Text.Json.Utf8JsonReader._tokenType, System.Text.Json.Dictionary, System.Text.Json.JsonConstants.EscapableChars, System.Text.Json.Utf8JsonReader.IsLastSpan, System.ReadOnlySpan< T >.Length, System.ReadOnlySpan< T >.Slice(), System.Text.Json.ThrowHelper.ThrowJsonReaderException(), System.Text.Json.Utf8JsonReader.ValidateHexDigits(), and System.Text.Json.Utf8JsonReader.ValueSpan.

Referenced by System.Text.Json.Utf8JsonReader.ConsumeString().