private static bool InterfaceCharMoveNext(ref RuneEnumerator e) { if (e.State is IEnumerator <char> enumerator) { if (!enumerator.MoveNext()) { return(false); } char highSurrogate = enumerator.Current; if (Rune.TryCreate(highSurrogate, out Rune rune)) { e.Current = rune; return(true); } if (!enumerator.MoveNext()) { return(false); } char lowSurrogate = enumerator.Current; if (Rune.TryCreate(highSurrogate, lowSurrogate, out rune)) { e.Current = rune; return(true); } } return(false); }
private static bool StringMoveNext(ref RuneEnumerator e) { if (e._stringEnumerator.MoveNext()) { e.Current = e._stringEnumerator.Current; return(true); } return(false); }
private static bool InterfaceRuneMoveNext(ref RuneEnumerator e) { if (e.State is IEnumerator <Rune> enumerator && enumerator.MoveNext()) { e.Current = enumerator.Current; return(true); } return(false); }
private static bool Utf8MoveNext(ref RuneEnumerator e) { if (e._utf8Enumerator.MoveNext()) { e.Current = e._utf8Enumerator.Current; return(true); } return(false); }
public readonly override string ToString() { RuneEnumerator runes = this; StringBuilder builder = new(); Span <char> buffer = stackalloc char[4]; foreach (Rune rune in runes) { int encoded = rune.EncodeToUtf16(buffer); builder.Append(buffer.Slice(0, encoded)); } return(builder.ToString()); }
private static bool BuilderMoveNext(ref RuneEnumerator e) { TryReturnFromChunk: if (e._spanEnumerator.MoveNext()) { e.Current = e._spanEnumerator.Current; return(true); } if (e._builderEnumerator.MoveNext()) { var chunkSpan = e._builderEnumerator.Current.Span; e._spanEnumerator = chunkSpan.EnumerateRunes(); goto TryReturnFromChunk; } return(false); }
public Utf8Enumerator(RuneEnumerator runes) : this() { _runeEnumerator = runes; }
public static Utf8Enumerator GetUtf8Enumerator(this RuneEnumerator runes) { return(new Utf8Enumerator(runes)); }