9 byte* ptr = stackalloc
byte[4];
14 for (
int i = 0; i < 3; i++)
16 ptr[i].TryFormat(span.
Slice(num), out charsWritten);
17 int num2 = num + charsWritten;
21 ptr[3].TryFormat(span.
Slice(num), out charsWritten);
22 return new string(span.
Slice(0, num + charsWritten));
25 private unsafe
static bool Parse(
string name,
byte* numbers,
int start,
int end)
27 fixed (
char* name2 = name)
31 *numbers = (byte)(num >> 24);
32 numbers[1] = (byte)(num >> 16);
33 numbers[2] = (byte)(num >> 8);
34 numbers[3] = (byte)num;
36 return *numbers == 127;
42 for (
int i = 0; i < span.
Length; i++)
48 num = num * 10 + c - 48;
57 internal unsafe
static bool IsValid(
char* name,
int start, ref
int end,
bool allowIPv6,
bool notImplicitFile,
bool unknownScheme)
59 if (allowIPv6 || unknownScheme)
66 internal unsafe
static bool IsValidCanonical(
char* name,
int start, ref
int end,
bool allowIPv6,
bool notImplicitFile)
77 if (c ==
']' || c ==
'/' || c ==
'%')
82 else if (c ==
'/' || c ==
'\\' || (notImplicitFile && (c ==
':' || c ==
'?' || c ==
'#')))
86 if (c <=
'9' && c >=
'0')
88 if (!flag && c ==
'0')
97 num2 = num2 * 10 + (name[
start] - 48);
109 if (!flag || (num2 > 0 && flag2))
120 bool flag3 = num == 3 && flag;
131 long* ptr = stackalloc
long[4];
136 for (i =
start; i < end; i++)
149 if (c ==
'x' || c ==
'X')
161 if ((num == 10 || num == 16) &&
'0' <= c && c <=
'9')
165 else if (num == 8 &&
'0' <= c && c <=
'7')
169 else if (num == 16 &&
'a' <= c && c <=
'f')
175 if (num != 16 ||
'A' > c || c >
'F')
181 num2 = num2 * num + num4;
182 if (num2 > uint.MaxValue)
188 if (i >= end || name[i] !=
'.')
192 if (num3 >= 3 || !flag || num2 > 255)
207 if ((c = name[i]) !=
'/' && c !=
'\\' && (!notImplicitFile || (c !=
':' && c !=
'?' && c !=
'#')))
217 if (*ptr > uint.MaxValue)
223 if (ptr[1] > 16777215)
227 return (*ptr << 24) | (ptr[1] & 0xFFFFFF);
233 return (*ptr << 24) | ((ptr[1] & 0xFF) << 16) | (ptr[2] & 0xFFFF);
239 return (*ptr << 24) | ((ptr[1] & 0xFF) << 16) | ((ptr[2] & 0xFF) << 8) | (ptr[3] & 0xFF);
static int ReadInt32BigEndian(ReadOnlySpan< byte > source)
static unsafe bool IsValid(char *name, int start, ref int end, bool allowIPv6, bool notImplicitFile, bool unknownScheme)
static unsafe bool IsValidCanonical(char *name, int start, ref int end, bool allowIPv6, bool notImplicitFile)
static unsafe bool Parse(string name, byte *numbers, int start, int end)
static unsafe string ParseCanonicalName(string str, int start, int end, ref bool isLoopback)
static int ParseHostNumber(ReadOnlySpan< char > str, int start, int end)
static unsafe long ParseNonCanonical(char *name, int start, ref int end, bool notImplicitFile)
Span< T > Slice(int start)