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

◆ DecodeFromUtf16()

static OperationStatus System.Text.Rune.DecodeFromUtf16 ( ReadOnlySpan< char > source,
out Rune result,
out int charsConsumed )
inlinestatic

Definition at line 168 of file Rune.cs.

169 {
170 if (!source.IsEmpty)
171 {
172 char c = source[0];
173 if (TryCreate(c, out result))
174 {
175 charsConsumed = 1;
176 return OperationStatus.Done;
177 }
178 if (source.Length > 1)
179 {
180 char lowSurrogate = source[1];
181 if (TryCreate(c, lowSurrogate, out result))
182 {
183 charsConsumed = 2;
184 return OperationStatus.Done;
185 }
186 }
187 else if (char.IsHighSurrogate(c))
188 {
189 goto IL_004c;
190 }
191 charsConsumed = 1;
192 result = ReplacementChar;
193 return OperationStatus.InvalidData;
194 }
195 goto IL_004c;
196 IL_004c:
197 charsConsumed = source.Length;
198 result = ReplacementChar;
199 return OperationStatus.NeedMoreData;
200 }
static Rune ReplacementChar
Definition Rune.cs:53
static bool TryCreate(char ch, out Rune result)
Definition Rune.cs:511

References System.Text.Rune.ReplacementChar, System.source, and System.Text.Rune.TryCreate().

Referenced by System.Text.Encodings.Web.TextEncoder.EncodeCore(), System.Text.Encoding.GetByteCountWithFallback(), System.Text.Encoding.GetBytesWithFallback(), System.Globalization.CompareInfo.IcuIsSortable(), and System.Text.Encodings.Web.TextEncoder.TryEncodeUnicodeScalarUtf8().