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

◆ GetBytes() [4/9]

override int System.Text.BinHexEncoding.GetBytes ( char[] chars,
int charIndex,
int charCount,
byte[] bytes,
int byteIndex )
inline

Definition at line 23 of file BinHexEncoding.cs.

24 {
25 if (chars == null)
26 {
27 throw new ArgumentNullException("chars");
28 }
29 if (charIndex < 0)
30 {
31 throw new ArgumentOutOfRangeException("charIndex", System.SR.ValueMustBeNonNegative);
32 }
33 if (charIndex > chars.Length)
34 {
35 throw new ArgumentOutOfRangeException("charIndex", System.SR.Format(System.SR.OffsetExceedsBufferSize, chars.Length));
36 }
37 if (charCount < 0)
38 {
39 throw new ArgumentOutOfRangeException("charCount", System.SR.ValueMustBeNonNegative);
40 }
41 if (charCount > chars.Length - charIndex)
42 {
43 throw new ArgumentOutOfRangeException("charCount", System.SR.Format(System.SR.SizeExceedsRemainingBufferSpace, chars.Length - charIndex));
44 }
45 if (bytes == null)
46 {
47 throw new ArgumentNullException("bytes");
48 }
49 if (byteIndex < 0)
50 {
51 throw new ArgumentOutOfRangeException("byteIndex", System.SR.ValueMustBeNonNegative);
52 }
53 if (byteIndex > bytes.Length)
54 {
55 throw new ArgumentOutOfRangeException("byteIndex", System.SR.Format(System.SR.OffsetExceedsBufferSize, bytes.Length));
56 }
58 if (byteCount < 0 || byteCount > bytes.Length - byteIndex)
59 {
60 throw new ArgumentException(System.SR.XmlArrayTooSmall, "bytes");
61 }
62 if (charCount > 0 && !System.HexConverter.TryDecodeFromUtf16(chars.AsSpan(charIndex, charCount), bytes.AsSpan(byteIndex, byteCount), out var charsProcessed))
63 {
64 int num = charsProcessed + charIndex;
65 throw new FormatException(System.SR.Format(System.SR.XmlInvalidBinHexSequence, new string(chars, num, 2), num));
66 }
67 return byteCount;
68 }
static bool TryDecodeFromUtf16(ReadOnlySpan< char > chars, Span< byte > bytes)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ValueMustBeNonNegative
Definition SR.cs:296
static string XmlInvalidBinHexSequence
Definition SR.cs:338
static string SizeExceedsRemainingBufferSpace
Definition SR.cs:324
static string OffsetExceedsBufferSize
Definition SR.cs:322
static string XmlArrayTooSmall
Definition SR.cs:348
Definition SR.cs:7
override int GetByteCount(char[] chars, int index, int count)

References System.byteCount, System.byteIndex, System.bytes, System.charCount, System.charIndex, System.chars, System.SR.Format(), System.Text.BinHexEncoding.GetByteCount(), System.SR.OffsetExceedsBufferSize, System.SR.SizeExceedsRemainingBufferSpace, System.HexConverter.TryDecodeFromUtf16(), System.SR.ValueMustBeNonNegative, System.SR.XmlArrayTooSmall, and System.SR.XmlInvalidBinHexSequence.