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

◆ UrlEncodeBytesToBytesInternal()

static byte[] System.Net.WebClient.UrlEncodeBytesToBytesInternal ( byte[] bytes,
int offset,
int count,
bool alwaysCreateReturnValue )
inlinestaticprivate

Definition at line 1375 of file WebClient.cs.

1376 {
1377 int num = 0;
1378 int num2 = 0;
1379 for (int i = 0; i < count; i++)
1380 {
1381 char c = (char)bytes[offset + i];
1382 if (c == ' ')
1383 {
1384 num++;
1385 }
1386 else if (!IsSafe(c))
1387 {
1388 num2++;
1389 }
1390 }
1391 if (!alwaysCreateReturnValue && num == 0 && num2 == 0)
1392 {
1393 return bytes;
1394 }
1395 byte[] array = new byte[count + num2 * 2];
1396 int num3 = 0;
1397 for (int j = 0; j < count; j++)
1398 {
1399 byte b = bytes[offset + j];
1400 char c2 = (char)b;
1401 if (IsSafe(c2))
1402 {
1403 array[num3++] = b;
1404 continue;
1405 }
1406 if (c2 == ' ')
1407 {
1408 array[num3++] = 43;
1409 continue;
1410 }
1411 array[num3++] = 37;
1412 array[num3++] = (byte)System.HexConverter.ToCharLower(b >> 4);
1413 array[num3++] = (byte)System.HexConverter.ToCharLower(b);
1414 }
1415 return array;
1416 }
static char ToCharLower(int value)
static bool IsSafe(char ch)

References System.array, System.bytes, System.count, System.Net.WebClient.IsSafe(), System.offset, and System.HexConverter.ToCharLower().

Referenced by System.Net.WebClient.UrlEncode().