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

◆ CheckUTF8DeclarationEncoding()

static void System.Xml.EncodingStreamWrapper.CheckUTF8DeclarationEncoding ( byte[] buffer,
int offset,
int count,
SupportedEncoding e,
SupportedEncoding expectedEnc )
inlinestaticprivate

Definition at line 382 of file EncodingStreamWrapper.cs.

383 {
384 byte b = 0;
385 int num = -1;
386 int num2 = offset + Math.Min(count, 128);
387 int num3 = 0;
388 int num4 = 0;
389 for (num3 = offset + 2; num3 < num2; num3++)
390 {
391 if (b != 0)
392 {
393 if (buffer[num3] == b)
394 {
395 b = 0;
396 }
397 }
398 else if (buffer[num3] == 39 || buffer[num3] == 34)
399 {
400 b = buffer[num3];
401 }
402 else if (buffer[num3] == 61)
403 {
404 if (num4 == 1)
405 {
406 num = num3;
407 break;
408 }
409 num4++;
410 }
411 else if (buffer[num3] == 63)
412 {
413 break;
414 }
415 }
416 if (num == -1)
417 {
418 if (e != 0 && expectedEnc == SupportedEncoding.None)
419 {
421 }
422 return;
423 }
424 if (num < 28)
425 {
427 }
428 num3 = num - 1;
429 while (IsWhitespace(buffer[num3]))
430 {
431 num3--;
432 }
433 if (!Compare(s_encodingAttr, buffer, num3 - s_encodingAttr.Length + 1))
434 {
435 if (e == SupportedEncoding.UTF8 || expectedEnc != SupportedEncoding.None)
436 {
437 return;
438 }
440 }
441 for (num3 = num + 1; num3 < num2 && IsWhitespace(buffer[num3]); num3++)
442 {
443 }
444 if (buffer[num3] != 39 && buffer[num3] != 34)
445 {
447 }
448 b = buffer[num3];
449 int num5 = num3++;
450 for (; buffer[num3] != b && num3 < num2; num3++)
451 {
452 }
453 if (buffer[num3] != b)
454 {
456 }
457 int num6 = num5 + 1;
458 int num7 = num3 - num6;
459 SupportedEncoding supportedEncoding = e;
461 {
462 supportedEncoding = SupportedEncoding.UTF8;
463 }
465 {
466 supportedEncoding = SupportedEncoding.UTF16LE;
467 }
469 {
470 supportedEncoding = SupportedEncoding.UTF16BE;
471 }
473 {
474 if (e == SupportedEncoding.UTF8)
475 {
477 }
478 }
479 else
480 {
482 }
483 if (e != supportedEncoding)
484 {
486 }
487 }
static string XmlDeclarationRequired
Definition SR.cs:362
static string XmlMalformedDecl
Definition SR.cs:458
Definition SR.cs:7
static readonly byte[] s_encodingUnicodeLE
static bool CompareCaseInsensitive(byte[] key, byte[] buffer, int offset)
static void ThrowEncodingMismatch(string declEnc, SupportedEncoding enc)
static readonly byte[] s_encodingUnicodeBE
static bool Compare(byte[] key, byte[] buffer, int offset)
static readonly UTF8Encoding s_safeUTF8

References System.buffer, System.Xml.EncodingStreamWrapper.Compare(), System.Xml.EncodingStreamWrapper.CompareCaseInsensitive(), System.count, System.Xml.Dictionary, System.Xml.EncodingStreamWrapper.IsWhitespace(), System.Math.Min(), System.offset, System.Xml.EncodingStreamWrapper.s_encodingAttr, System.Xml.EncodingStreamWrapper.s_encodingUnicode, System.Xml.EncodingStreamWrapper.s_encodingUnicodeBE, System.Xml.EncodingStreamWrapper.s_encodingUnicodeLE, System.Xml.EncodingStreamWrapper.s_encodingUTF8, System.Xml.EncodingStreamWrapper.s_safeUTF8, System.Xml.EncodingStreamWrapper.ThrowEncodingMismatch(), System.SR.XmlDeclarationRequired, System.Xml.XmlException, and System.SR.XmlMalformedDecl.

Referenced by System.Xml.EncodingStreamWrapper.EncodingStreamWrapper(), and System.Xml.EncodingStreamWrapper.ProcessBuffer().