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

◆ GetByteCount() [2/5]

unsafe override int System.Text.OSEncoder.GetByteCount ( char * chars,
int count,
bool flush )
inlinevirtual

Reimplemented from System.Text.Encoder.

Definition at line 66 of file OSEncoder.cs.

67 {
68 if (chars == null)
69 {
70 throw new ArgumentNullException("chars", System.SR.ArgumentNull_Array);
71 }
72 if (count < 0)
73 {
74 throw new ArgumentOutOfRangeException("count", System.SR.ArgumentOutOfRange_NeedNonNegNum);
75 }
76 bool flag = count > 0 && !flush && char.IsHighSurrogate(chars[count - 1]);
77 if (flag)
78 {
79 count--;
80 }
81 if (_charLeftOver == '\0')
82 {
83 if (count <= 0)
84 {
85 return 0;
86 }
87 return OSEncoding.WideCharToMultiByte(_encoding.CodePage, chars, count, null, 0);
88 }
89 if (count == 0 && !flag && !flush)
90 {
91 return 0;
92 }
93 return ConvertWithLeftOverChar(chars, count, null, 0);
94 }
static string ArgumentNull_Array
Definition SR.cs:24
static string ArgumentOutOfRange_NeedNonNegNum
Definition SR.cs:32
Definition SR.cs:7
virtual int CodePage
Definition Encoding.cs:515
unsafe int ConvertWithLeftOverChar(char *chars, int count, byte *bytes, int byteCount)
Definition OSEncoder.cs:48
readonly Encoding _encoding
Definition OSEncoder.cs:9

References System.Text.OSEncoder._charLeftOver, System.Text.OSEncoder._encoding, System.SR.ArgumentNull_Array, System.SR.ArgumentOutOfRange_NeedNonNegNum, System.chars, System.Text.Encoding.CodePage, System.Text.OSEncoder.ConvertWithLeftOverChar(), System.count, and System.Text.OSEncoding.WideCharToMultiByte().