22 instantiations of Rune
Microsoft.CodeAnalysis.CSharp.Features (1)
ConvertToRawString\ConvertToRawStringHelpers.cs (1)
119!IsFormatOrControl(Rune.GetUnicodeCategory(new Rune(ch, characters[i + 1]))))
System.Private.CoreLib (13)
src\runtime\src\libraries\Common\src\System\Number.Formatting.Common.cs (1)
887var r = new Rune(ch);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Char.cs (1)
212new Rune(this).TryEncodeToUtf8(utf8Destination, out bytesWritten);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Globalization\DateTimeFormat.cs (1)
756var r = new Rune(ch);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Globalization\TextInfo.cs (4)
535return new Rune(lowerChars[0], lowerChars[1]); 539return new Rune(lowerChar); 557return new Rune(upperChars[0], upperChars[1]); 561return new Rune(upperChar);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\ASCIIEncoding.cs (1)
811value = new Rune(b);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\Latin1Encoding.cs (1)
692value = new Rune(b);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\Rune.cs (4)
148public static explicit operator Rune(char ch) => new Rune(ch); 151public static explicit operator Rune(uint value) => new Rune(value); 153public static explicit operator Rune(int value) => new Rune(value); 1288internal static Rune UnsafeCreate(uint scalarValue) => new Rune(scalarValue, false);
System.Private.Uri (1)
System\IriHelper.cs (1)
151rune = new Rune(ch, ch2);
System.Runtime.Numerics (1)
src\runtime\src\libraries\Common\src\System\Number.Formatting.Common.cs (1)
887var r = new Rune(ch);
System.Text.Encodings.Web (5)
System\Text\Encodings\Web\DefaultHtmlEncoder.cs (1)
54=> !_innerEncoder.IsScalarValueAllowed(new Rune(unicodeScalar));
System\Text\Encodings\Web\DefaultJavaScriptEncoder.cs (1)
66=> !_innerEncoder.IsScalarValueAllowed(new Rune(unicodeScalar));
System\Text\Encodings\Web\DefaultUrlEncoder.cs (1)
129=> !_innerEncoder.IsScalarValueAllowed(new Rune(unicodeScalar));
System\Text\Encodings\Web\OptimizedInboxTextEncoder.Ascii.cs (1)
46Rune rune = new Rune(i); // guaranteed to succeed
System\Text\Encodings\Web\OptimizedInboxTextEncoder.cs (1)
118int innerCharsWritten = _scalarEscaper.EncodeUtf16(new Rune(unicodeScalar), destination);
System.Text.Json (1)
System\Text\Json\Reader\JsonReaderHelper.Unescaping.cs (1)
487var rune = new Rune(scalar);
451 references to Rune
aspire (1)
Utils\EmojiWidth.cs (1)
43var rune = enumerator.Current;
Microsoft.AspNetCore.Components (2)
src\aspnetcore\src\Shared\UrlDecoder\UrlDecoder.cs (2)
524if (!System.Text.Rune.TryCreate(currentDecodeBits, out var rune) || !rune.TryEncodeToUtf16(buffer.Slice(destinationIndex), out var charsWritten))
Microsoft.AspNetCore.Http.Abstractions (2)
src\aspnetcore\src\Shared\UrlDecoder\UrlDecoder.cs (2)
524if (!System.Text.Rune.TryCreate(currentDecodeBits, out var rune) || !rune.TryEncodeToUtf16(buffer.Slice(destinationIndex), out var charsWritten))
Microsoft.AspNetCore.Server.Kestrel.Core (2)
src\aspnetcore\src\Shared\UrlDecoder\UrlDecoder.cs (2)
524if (!System.Text.Rune.TryCreate(currentDecodeBits, out var rune) || !rune.TryEncodeToUtf16(buffer.Slice(destinationIndex), out var charsWritten))
Microsoft.AspNetCore.WebUtilities (2)
src\aspnetcore\src\Shared\UrlDecoder\UrlDecoder.cs (2)
524if (!System.Text.Rune.TryCreate(currentDecodeBits, out var rune) || !rune.TryEncodeToUtf16(buffer.Slice(destinationIndex), out var charsWritten))
Microsoft.CodeAnalysis.CSharp.Features (6)
ConvertToRawString\ConvertToRawStringHelpers.cs (1)
119!IsFormatOrControl(Rune.GetUnicodeCategory(new Rune(ch, characters[i + 1]))))
src\roslyn\src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (5)
155if (!TryGetNextRune(arrayCreationElements, i, out var rune, out var bytesConsumed) || 181static bool IsControlOrFormatRune(Rune rune) 182=> Rune.GetUnicodeCategory(rune) is UnicodeCategory.Control or UnicodeCategory.Format 192private static bool TryGetNextRune(ImmutableArray<IOperation> arrayCreationElements, int startIndex, out Rune rune, out int bytesConsumed) 213return Rune.DecodeFromUtf8(array, out rune, out bytesConsumed) == System.Buffers.OperationStatus.Done;
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\RuneExtensions.cs (1)
15public static bool TryGetEscapeCharacter(this Rune rune, out char escapedChar)
Microsoft.CodeAnalysis.Features.ExternalAccess (1)
AspNetCore\EmbeddedLanguages\AspNetCoreVirtualChar.cs (1)
28get => char.IsSurrogate(VirtualChar) ? Rune.ReplacementChar.Value : VirtualChar;
Microsoft.ML.Tokenizers (2)
Utils\Helpers.netcoreapp.cs (2)
83Rune.DecodeFromUtf16(text.Slice(textIndex), out Rune rune, out int charsConsumed);
Microsoft.ML.Tokenizers.Tests (2)
src\Microsoft.ML.Tokenizers\Utils\Helpers.netcoreapp.cs (2)
83Rune.DecodeFromUtf16(text.Slice(textIndex), out Rune rune, out int charsConsumed);
Microsoft.Net.Http.Headers (3)
ContentDispositionHeaderValue.cs (3)
644Rune.DecodeFromUtf16(remaining.Slice(i), out Rune rune, out var runeLength); 659private static void EncodeToUtf8Hex(Rune rune, StringBuilder builder)
Microsoft.TemplateEngine.Cli (1)
src\sdk\artifacts\obj\Microsoft.TemplateEngine.Cli\External\Wcwidth\UnicodeCalculator.cs (1)
136public static int GetWidth(Rune value, Unicode? version = null)
System.Collections.Immutable (1)
System\Collections\Frozen\Constants.cs (1)
64typeof(T) == typeof(Rune) ||
System.Formats.Tar (1)
System\Formats\Tar\TarHeader.Write.cs (1)
992foreach (Rune rune in text.EnumerateRunes())
System.Private.CoreLib (365)
src\runtime\src\libraries\Common\src\System\Number.Formatting.Common.cs (1)
887var r = new Rune(ch);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Char.cs (7)
256if (Rune.DecodeFromUtf8(utf8Text, out Rune rune, out int bytesConsumed) != Buffers.OperationStatus.Done || 273if (Rune.DecodeFromUtf8(utf8Text, out Rune rune, out int bytesConsumed) != Buffers.OperationStatus.Done || 1109return Rune.UnsafeCreate((uint)utf32).ToString(); 2003if (Rune.DecodeFromUtf8(utf8Text, out Rune rune, out bytesConsumed) != Buffers.OperationStatus.Done ||
src\runtime\src\libraries\System.Private.CoreLib\src\System\CodeDom\Compiler\IndentedTextWriter.cs (11)
118/// Writes out the specified <see cref="Rune"/>, inserting tabs at the start of every line. 120/// <param name="value">The <see cref="Rune"/> to write.</param> 121public override void Write(Rune value) 211/// Asynchronously writes the specified <see cref="Rune"/> to the underlying <see cref="TextWriter"/>, inserting 214/// <param name="value">The <see cref="Rune"/> to write.</param> 216public override async Task WriteAsync(Rune value) 319/// Writes out the specified <see cref="Rune"/>, followed by a line terminator, inserting tabs at the start of every line. 321/// <param name="value">The <see cref="Rune"/> to write.</param> 322public override void WriteLine(Rune value) 441/// Asynchronously writes the specified <see cref="Rune"/> to the underlying <see cref="TextWriter"/> followed by a line terminator, inserting tabs 446public override async Task WriteLineAsync(Rune value)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Globalization\CharUnicodeInfo.cs (1)
196internal static GraphemeClusterBreakType GetGraphemeClusterBreakType(Rune rune)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.cs (11)
155/// Indicates whether a specified <see cref="Rune"/> is sortable. 162public static unsafe bool IsSortable(Rune value) 164Span<char> valueAsUtf16 = stackalloc char[Rune.MaxUtf16CharsPerRune]; 1022/// Searches for the first occurrence of a <see cref="Rune"/> within a source string. 1025/// <param name="value">The <see cref="Rune"/> to locate within <paramref name="source"/>.</param> 1034public unsafe int IndexOf(ReadOnlySpan<char> source, Rune value, CompareOptions options = CompareOptions.None) 1036Span<char> valueAsUtf16 = stackalloc char[Rune.MaxUtf16CharsPerRune]; 1394/// Searches for the last occurrence of a <see cref="Rune"/> within a source string. 1397/// <param name="value">The <see cref="Rune"/> to locate within <paramref name="source"/>.</param> 1406public unsafe int LastIndexOf(ReadOnlySpan<char> source, Rune value, CompareOptions options = CompareOptions.None) 1408Span<char> valueAsUtf16 = stackalloc char[Rune.MaxUtf16CharsPerRune];
src\runtime\src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.Icu.cs (3)
828if (Rune.DecodeFromUtf16(text, out Rune result, out int charsConsumed) != OperationStatus.Done) 833UnicodeCategory category = Rune.GetUnicodeCategory(result);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Globalization\DateTimeFormat.cs (1)
756var r = new Rune(ch);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Globalization\HebrewNumber.cs (2)
214Rune.DecodeLastFromUtf8(MemoryMarshal.AsBytes(outputBuffer.AsSpan()), out Rune value, out int bytesConsumed);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Globalization\Ordinal.Utf8.cs (12)
66OperationStatus statusA = Rune.DecodeFromUtf8(spanA, out Rune runeA, out int bytesConsumedA); 67OperationStatus statusB = Rune.DecodeFromUtf8(spanB, out Rune runeB, out int bytesConsumedB); 77if (Rune.ToUpperInvariant(runeA) != Rune.ToUpperInvariant(runeB)) 376OperationStatus statusA = Rune.DecodeFromUtf8(spanA, out Rune runeA, out int bytesConsumedA); 377OperationStatus statusB = Rune.DecodeFromUtf8(spanB, out Rune runeB, out int bytesConsumedB); 387if (Rune.ToUpperInvariant(runeA) != Rune.ToUpperInvariant(runeB))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Globalization\TextInfo.cs (6)
525public unsafe Rune ToLower(Rune value) 528ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]); 547public unsafe Rune ToUpper(Rune value) 550ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Guid.cs (6)
942if (Rune.DecodeFromUtf8(srcUtf8Span.Slice(i), out Rune current, out int bytesConsumed) != Buffers.OperationStatus.Done) 948if (!Rune.IsWhiteSpace(current)) 973if (Rune.DecodeFromUtf8(srcUtf8Span.Slice(i), out Rune current, out int bytesConsumed) != Buffers.OperationStatus.Done) 979if (!Rune.IsWhiteSpace(current))
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\BinaryWriter.cs (2)
179if (!Rune.TryCreate(ch, out Rune rune)) // optimistically assume UTF-8 code path (which uses Rune) will be hit
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\TextWriter.CreateBroadcasting.cs (4)
135public override void Write(Rune value) 303public override void WriteLine(Rune value) 471public override async Task WriteAsync(Rune value) 519public override async Task WriteLineAsync(Rune value)
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\TextWriter.cs (16)
145public virtual unsafe void Write(Rune value) 148ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]); 380public virtual unsafe void WriteLine(Rune value) 383ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]); 600public virtual unsafe Task WriteAsync(Rune value) 602ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]); 694public virtual unsafe Task WriteLineAsync(Rune value) 696ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]); 825public override void Write(Rune value) { } 846public override Task WriteAsync(Rune value) => Task.CompletedTask; 853public override void WriteLine(Rune value) { } 874public override Task WriteLineAsync(Rune value) => Task.CompletedTask; 931public override void Write(Rune value) => _out.Write(value); 997public override void WriteLine(Rune value) => _out.WriteLine(value); 1075public override Task WriteAsync(Rune value) 1139public override Task WriteLineAsync(Rune value)
src\runtime\src\libraries\System.Private.CoreLib\src\System\MemoryExtensions.Globalization.cs (4)
429/// Returns an enumeration of <see cref="Rune"/> from the provided span. 432/// Invalid sequences will be represented in the enumeration by <see cref="Rune.ReplacementChar"/>. 440/// Returns an enumeration of <see cref="Rune"/> from the provided span. 443/// Invalid sequences will be represented in the enumeration by <see cref="Rune.ReplacementChar"/>.
src\runtime\src\libraries\System.Private.CoreLib\src\System\MemoryExtensions.Trim.Utf8.cs (19)
18Debug.Assert(!Rune.IsWhiteSpace(Rune.ReplacementChar)); 22_ = Rune.DecodeFromUtf8(span, out Rune current, out int bytesConsumed); 24if (!Rune.IsWhiteSpace(current)) 43Debug.Assert(!Rune.IsWhiteSpace(Rune.ReplacementChar)); 50_ = Rune.DecodeFromUtf8(span, out Rune first, out int firstBytesConsumed); 52if (Rune.IsWhiteSpace(first)) 58_ = Rune.DecodeLastFromUtf8(span, out Rune last, out int lastBytesConsumed); 60if (Rune.IsWhiteSpace(last)) 73_ = Rune.DecodeFromUtf8(span, out Rune current, out int bytesConsumed); 75if (!Rune.IsWhiteSpace(current)) 85_ = Rune.DecodeLastFromUtf8(span, out Rune current, out int bytesConsumed); 87if (!Rune.IsWhiteSpace(current))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Net\WebUtility.cs (2)
119Rune.TryCreate(ch, input[i + 1], out Rune rune))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Reflection\AssemblyName.cs (3)
335if (Rune.DecodeFromUtf16(stringToEscape, out Rune r, out int charsConsumed) != OperationStatus.Done) 337r = Rune.ReplacementChar;
src\runtime\src\libraries\System.Private.CoreLib\src\System\String.Comparison.cs (6)
524public bool EndsWith(Rune value) 542public unsafe bool EndsWith(Rune value, StringComparison comparisonType) 545ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]); 1142public bool StartsWith(Rune value) 1160public unsafe bool StartsWith(Rune value, StringComparison comparisonType) 1163ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);
src\runtime\src\libraries\System.Private.CoreLib\src\System\String.cs (2)
605/// Returns an enumeration of <see cref="Rune"/> from this string. 608/// Invalid sequences will be represented in the enumeration by <see cref="Rune.ReplacementChar"/>.
src\runtime\src\libraries\System.Private.CoreLib\src\System\String.Manipulation.cs (10)
1478public unsafe string Replace(Rune oldRune, Rune newRune) 1485ReadOnlySpan<char> oldChars = oldRune.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]); 1486ReadOnlySpan<char> newChars = newRune.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]); 1694public string[] Split(Rune separator, StringSplitOptions options = StringSplitOptions.None) 1706public unsafe string[] Split(Rune separator, int count, StringSplitOptions options = StringSplitOptions.None) 1723ReadOnlySpan<char> separatorSpan = separator.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]); 2704public unsafe string Trim(Rune trimRune) 2779public unsafe string TrimStart(Rune trimRune) 2846public unsafe string TrimEnd(Rune trimRune)
src\runtime\src\libraries\System.Private.CoreLib\src\System\String.Searching.cs (16)
53public bool Contains(Rune value) 69public bool Contains(Rune value, StringComparison comparisonType) 351public int IndexOf(Rune value) 366public int IndexOf(Rune value, int startIndex) 383public int IndexOf(Rune value, int startIndex, int count) 398public int IndexOf(Rune value, StringComparison comparisonType) 415public int IndexOf(Rune value, int startIndex, StringComparison comparisonType) 433public unsafe int IndexOf(Rune value, int startIndex, int count, StringComparison comparisonType) 441ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]); 681public int LastIndexOf(Rune value) 696public int LastIndexOf(Rune value, int startIndex) 713public int LastIndexOf(Rune value, int startIndex, int count) 728public int LastIndexOf(Rune value, StringComparison comparisonType) 745public int LastIndexOf(Rune value, int startIndex, StringComparison comparisonType) 763public unsafe int LastIndexOf(Rune value, int startIndex, int count, StringComparison comparisonType) 776ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\ASCIIEncoding.cs (5)
765internal sealed override bool TryGetByteCount(Rune value, out int byteCount) 779internal sealed override OperationStatus EncodeRune(Rune value, Span<byte> bytes, out int bytesWritten) 802internal sealed override OperationStatus DecodeFirstRune(ReadOnlySpan<byte> bytes, out Rune value, out int bytesConsumed) 819value = Rune.ReplacementChar; 828value = Rune.ReplacementChar;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\DecoderFallback.cs (6)
231private Rune GetNextRune() 239if (!Rune.TryCreate(ch, out Rune rune) && !Rune.TryCreate(ch, GetNextChar(), out rune)) 251Rune thisRune; 271Rune thisRune;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\DecoderNLS.cs (2)
239switch (_encoding.DecodeFirstRune(combinedBuffer, out Rune value, out int combinedBufferBytesConsumed)) 297switch (_encoding.DecodeFirstRune(combinedBuffer, out Rune value, out int combinedBufferBytesConsumed))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\EncoderFallback.cs (6)
198Rune thisRune; 248Rune thisRune; 277private Rune GetNextRune() 280if (Rune.TryCreate(firstChar, out Rune value) || Rune.TryCreate(firstChar, GetNextChar(), out value))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\EncoderNLS.cs (4)
281if (Rune.TryCreate(_charLeftOver, secondChar, out Rune rune)) 356if (Rune.TryCreate(charLeftOver, secondChar, out Rune rune))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\Encoding.Internal.cs (10)
74internal virtual OperationStatus DecodeFirstRune(ReadOnlySpan<byte> bytes, out Rune value, out int bytesConsumed) 80internal virtual OperationStatus EncodeRune(Rune value, Span<byte> bytes, out int bytesWritten) 96/// Given a <see cref="Rune"/>, determines its byte count under the current <see cref="Encoding"/>. 97/// Returns <see langword="false"/> if the <see cref="Rune"/> cannot be represented in the 100internal virtual bool TryGetByteCount(Rune value, out int byteCount) 329if (Rune.DecodeFromUtf16(chars, out Rune firstScalarValue, out int charsConsumedThisIteration) == OperationStatus.NeedMoreData 606switch (Rune.DecodeFromUtf16(chars, out Rune firstScalarValue, out int charsConsumedThisIteration)) 928if (DecodeFirstRune(bytes, out Rune firstScalarValue, out int bytesConsumedThisIteration) == OperationStatus.NeedMoreData
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\Latin1Encoding.cs (4)
643internal sealed override bool TryGetByteCount(Rune value, out int byteCount) 660internal sealed override OperationStatus EncodeRune(Rune value, Span<byte> bytes, out int bytesWritten) 686internal sealed override OperationStatus DecodeFirstRune(ReadOnlySpan<byte> bytes, out Rune value, out int bytesConsumed) 699value = Rune.ReplacementChar;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\Rune.cs (111)
22/// assuming that the underlying <see cref="Rune"/> instance is well-formed. 30readonly struct Rune : IComparable, IComparable<Rune>, IEquatable<Rune> 35, IParsable<Rune> 36, ISpanParsable<Rune> 37, IUtf8SpanParsable<Rune> 72/// Creates a <see cref="Rune"/> from the provided UTF-16 code unit. 89/// Creates a <see cref="Rune"/> from the provided UTF-16 surrogate pair. 101/// Creates a <see cref="Rune"/> from the provided Unicode scalar value. 112/// Creates a <see cref="Rune"/> from the provided Unicode scalar value. 134public static bool operator ==(Rune left, Rune right) => left._value == right._value; 136public static bool operator !=(Rune left, Rune right) => left._value != right._value; 138public static bool operator <(Rune left, Rune right) => left._value < right._value; 140public static bool operator <=(Rune left, Rune right) => left._value <= right._value; 142public static bool operator >(Rune left, Rune right) => left._value > right._value; 144public static bool operator >=(Rune left, Rune right) => left._value >= right._value; 148public static explicit operator Rune(char ch) => new Rune(ch); 151public static explicit operator Rune(uint value) => new Rune(value); 153public static explicit operator Rune(int value) => new Rune(value); 183/// A <see cref="Rune"/> instance that represents the Unicode replacement character U+FFFD. 185public static Rune ReplacementChar => UnsafeCreate(UnicodeUtility.ReplacementChar); 227private static unsafe Rune ChangeCaseCultureAware(Rune rune, TextInfo textInfo, bool toUpper) 297public int CompareTo(Rune other) => this.Value - other.Value; // values don't span entire 32-bit domain; won't integer overflow 307/// Decodes the <see cref="Rune"/> at the beginning of the provided UTF-16 source buffer. 312/// and outs via <paramref name="result"/> the decoded <see cref="Rune"/> and via <paramref name="charsConsumed"/> the 313/// number of <see langword="char"/>s used in the input buffer to encode the <see cref="Rune"/>. 332public static OperationStatus DecodeFromUtf16(ReadOnlySpan<char> source, out Rune result, out int charsConsumed) 391/// Decodes the <see cref="Rune"/> at the beginning of the provided UTF-8 source buffer. 396/// and outs via <paramref name="result"/> the decoded <see cref="Rune"/> and via <paramref name="bytesConsumed"/> the 397/// number of <see langword="byte"/>s used in the input buffer to encode the <see cref="Rune"/>. 416public static OperationStatus DecodeFromUtf8(ReadOnlySpan<byte> source, out Rune result, out int bytesConsumed) 576/// Decodes the <see cref="Rune"/> at the end of the provided UTF-16 source buffer. 579/// This method is very similar to <see cref="DecodeFromUtf16(ReadOnlySpan{char}, out Rune, out int)"/>, but it allows 584public static OperationStatus DecodeLastFromUtf16(ReadOnlySpan<char> source, out Rune result, out int charsConsumed) 636/// Decodes the <see cref="Rune"/> at the end of the provided UTF-8 source buffer. 639/// This method is very similar to <see cref="DecodeFromUtf8(ReadOnlySpan{byte}, out Rune, out int)"/>, but it allows 644public static OperationStatus DecodeLastFromUtf8(ReadOnlySpan<byte> source, out Rune value, out int bytesConsumed) 721OperationStatus operationStatus = DecodeFromUtf8(source, out Rune tempRune, out int tempBytesConsumed); 753/// Encodes this <see cref="Rune"/> to a UTF-16 destination buffer. 771/// Encodes this <see cref="Rune"/> to a UTF-8 destination buffer. 788public override bool Equals([NotNullWhen(true)] object? obj) => (obj is Rune other) && Equals(other); 790public bool Equals(Rune other) => this == other; 798public unsafe bool Equals(Rune other, StringComparison comparisonType) 819/// Gets the <see cref="Rune"/> which begins at index <paramref name="index"/> in 826public static Rune GetRuneAt(string input, int index) 939/// Returns a <see cref="string"/> representation of this <see cref="Rune"/> instance. 975static bool IUtf8SpanParsable<Rune>.TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out Rune result) 991static Rune IUtf8SpanParsable<Rune>.Parse(ReadOnlySpan<byte> utf8Text, System.IFormatProvider? provider) 993if (DecodeFromUtf8(utf8Text, out Rune result, out int bytesConsumed) != OperationStatus.Done || bytesConsumed != utf8Text.Length) 1002static Rune IParsable<Rune>.Parse(string s, IFormatProvider? provider) 1006if (DecodeFromUtf16(s, out Rune result, out int charsConsumed) != OperationStatus.Done || charsConsumed != s.Length) 1015static bool IParsable<Rune>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out Rune result) 1027static Rune ISpanParsable<Rune>.Parse(ReadOnlySpan<char> s, IFormatProvider? provider) 1029if (DecodeFromUtf16(s, out Rune result, out int charsConsumed) != OperationStatus.Done || charsConsumed != s.Length) 1038static bool ISpanParsable<Rune>.TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out Rune result) 1053/// Attempts to create a <see cref="Rune"/> from the provided input value. 1055public static bool TryCreate(char ch, out Rune result) 1071/// Attempts to create a <see cref="Rune"/> from the provided UTF-16 surrogate pair. 1074public static bool TryCreate(char highSurrogate, char lowSurrogate, out Rune result) 1101/// Attempts to create a <see cref="Rune"/> from the provided input value. 1103public static bool TryCreate(int value, out Rune result) => TryCreate((uint)value, out result); 1106/// Attempts to create a <see cref="Rune"/> from the provided input value. 1109public static bool TryCreate(uint value, out Rune result) 1124/// Encodes this <see cref="Rune"/> to a UTF-16 destination buffer. 1143private static bool TryEncodeToUtf16(Rune value, Span<char> destination, out int charsWritten) 1168/// Encodes this <see cref="Rune"/> to a destination buffer as UTF-8 bytes. 1187private static bool TryEncodeToUtf8(Rune value, Span<byte> destination, out int bytesWritten) 1245/// Attempts to get the <see cref="Rune"/> which begins at index <paramref name="index"/> in 1253public static bool TryGetRuneAt(string input, int index, out Rune value) 1285/// Creates a <see cref="Rune"/> without performing validation on the input. 1288internal static Rune UnsafeCreate(uint scalarValue) => new Rune(scalarValue, false); 1292public static double GetNumericValue(Rune value) 1314public static UnicodeCategory GetUnicodeCategory(Rune value) 1326private static UnicodeCategory GetUnicodeCategoryNonAscii(Rune value) 1377public static bool IsControl(Rune value) 1391public static bool IsDigit(Rune value) 1403public static bool IsLetter(Rune value) 1415public static bool IsLetterOrDigit(Rune value) 1427public static bool IsLower(Rune value) 1439public static bool IsNumber(Rune value) 1451public static bool IsPunctuation(Rune value) 1456public static bool IsSeparator(Rune value) 1461public static bool IsSymbol(Rune value) 1466public static bool IsUpper(Rune value) 1478public static bool IsWhiteSpace(Rune value) 1496public static Rune ToLower(Rune value, CultureInfo culture) 1519public static Rune ToLowerInvariant(Rune value) 1545public static Rune ToUpper(Rune value, CultureInfo culture) 1568public static Rune ToUpperInvariant(Rune value) 1601public static Rune ToUpperOrdinal(Rune value) 1622public static Rune ToLowerOrdinal(Rune value) 1646if (obj is Rune other)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\RunePosition.cs (17)
15/// Invalid Unicode symbols will be represented by the <see cref="System.Text.Rune.ReplacementChar"/> value. 28/// Invalid Unicode symbols will be represented by <see cref="System.Text.Rune.ReplacementChar"/> 42/// Invalid Unicode symbols will be represented by <see cref="Rune.ReplacementChar"/> value. 47/// Unicode scalar value <see cref="System.Text.Rune"/> of the current symbol in Unicode data. 48/// Invalid Unicode symbols will be represented by <see cref="System.Text.Rune.ReplacementChar"/> value. 50public Rune Rune { get; } 67/// replaced by <see cref="System.Text.Rune.ReplacementChar"/> value. 78public RunePosition(Rune rune, int startIndex, int length, bool wasReplaced) 85if ((uint)length > Rune.MaxUtf8BytesPerRune) 131public void Deconstruct(out Rune rune, out int startIndex) 144public void Deconstruct(out Rune rune, out int startIndex, out int length) 223int scalarValue = Rune.ReadFirstRuneFromUtf16Buffer(_remaining); 226Rune rune = Rune.UnsafeCreate((uint)scalarValue); 233Current = new RunePosition(Rune.ReplacementChar, Current.StartIndex + Current.Length, 1, true); 301bool wasReplaced = Rune.DecodeFromUtf8(_remaining, out Rune rune, out int charsConsumed) != OperationStatus.Done;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\SpanRuneEnumerator.cs (6)
12public ref struct SpanRuneEnumerator : IEnumerator<Rune> 15private Rune _current; 23public Rune Current => _current; 36int scalarValue = Rune.ReadFirstRuneFromUtf16Buffer(_remaining); 40scalarValue = Rune.ReplacementChar.Value; 49_current = Rune.UnsafeCreate((uint)scalarValue);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\StringBuilder.cs (20)
666/// Returns an enumeration of <see cref="Rune"/> from this builder. 669/// Invalid sequences will be represented in the enumeration by <see cref="Rune.ReplacementChar"/>. 1056/// Appends the string representation of a specified <see cref="Rune"/> to this instance. 1060public unsafe StringBuilder Append(Rune value) 1063ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]); 1375public unsafe StringBuilder Insert(int index, Rune value) 1378ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]); 2307public StringBuilder Replace(Rune oldRune, Rune newRune) 2323public unsafe StringBuilder Replace(Rune oldRune, Rune newRune, int startIndex, int count) 2326ReadOnlySpan<char> oldChars = oldRune.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]); 2329ReadOnlySpan<char> newChars = newRune.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]); 2886/// Gets the <see cref="Rune"/> that begins at a specified position in this builder. 2892public Rune GetRuneAt(int index) 2894if (TryGetRuneAt(index, out Rune value)) 2903/// Attempts to get the <see cref="Rune"/> that begins at a specified position in this builder, and return a value that indicates whether the operation succeeded. 2912public bool TryGetRuneAt(int index, out Rune value) 2922OperationStatus status = Rune.DecodeFromUtf16(chars, out Rune result, out _);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\StringBuilderRuneEnumerator.cs (11)
10/// An enumerator for retrieving <see cref="Rune"/> instances from a <see cref="StringBuilder"/>. 12public struct StringBuilderRuneEnumerator : IEnumerable<Rune>, IEnumerator<Rune> 15private Rune _current; 26/// Gets the <see cref="Rune"/> at the current position of the enumerator. 28public readonly Rune Current => _current; 37/// Advances the enumerator to the next <see cref="Rune"/> of the builder. 55_current = Rune.ReplacementChar; 69/// Gets the <see cref="Rune"/> at the current position of the enumerator. 94readonly IEnumerator<Rune> IEnumerable<Rune>.GetEnumerator() => this;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\StringRuneEnumerator.cs (8)
10public struct StringRuneEnumerator : IEnumerable<Rune>, IEnumerator<Rune> 13private Rune _current; 23public Rune Current => _current; 36if (!Rune.TryGetRuneAt(_string, _nextIndex, out _current)) 39_current = Rune.ReplacementChar; 61IEnumerator<Rune> IEnumerable<Rune>.GetEnumerator() => this;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\Unicode\TextSegmentationUtility.cs (3)
19private delegate OperationStatus DecodeFirstRune<T>(ReadOnlySpan<T> input, out Rune rune, out int elementsConsumed); 21private static readonly DecodeFirstRune<char> _utf16Decoder = Rune.DecodeFromUtf16; 229_decoder(_buffer.Slice(CurrentCodeUnitOffset), out Rune thisRune, out _codeUnitLengthOfCurrentScalar);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8.cs (2)
201Rune.DecodeFromUtf8(source, out _, out int bytesConsumedJustNow); 287Rune.DecodeFromUtf8(source, out _, out int bytesConsumedJustNow);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\UTF8Encoding.cs (4)
769internal sealed override bool TryGetByteCount(Rune value, out int byteCount) 777internal sealed override OperationStatus EncodeRune(Rune value, Span<byte> bytes, out int bytesWritten) 785internal sealed override OperationStatus DecodeFirstRune(ReadOnlySpan<byte> bytes, out Rune value, out int bytesConsumed) 787return Rune.DecodeFromUtf8(bytes, out value, out bytesConsumed);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\UTF8Encoding.Sealed.cs (1)
14/// perform <see cref="Rune.ReplacementChar"/> substitution instead" semantics. This type allows for devirtualization
System.Private.Uri (12)
System\IriHelper.cs (5)
34if (Rune.TryCreate(highSurr, lowSurr, out Rune rune)) 148Rune rune; 153else if (!Rune.TryCreate(ch, out rune)) 155rune = Rune.ReplacementChar;
System\PercentEncodingHelper.cs (2)
87if (Rune.DecodeFromUtf8(MemoryMarshal.AsBytes(new ReadOnlySpan<uint>(ref temp))[..bytesLeftInBuffer], out Rune rune, out bytesConsumed) == OperationStatus.Done)
System\UriHelper.cs (3)
264if (Rune.DecodeFromUtf16(stringToEscape, out Rune r, out int charsConsumed) != OperationStatus.Done) 266r = Rune.ReplacementChar;
System\ValueStringBuilderExtensions.cs (2)
11public void Append(Rune rune) 36private void GrowAndAppend(Rune rune)
System.Runtime (1)
src\runtime\artifacts\obj\System.Runtime\Release\net11.0\System.Runtime.Forwards.cs (1)
820[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Text.Rune))]
System.Runtime.Numerics (8)
src\runtime\src\libraries\Common\src\System\Number.Formatting.Common.cs (1)
887var r = new Rune(ch);
System\Number.Polyfill.cs (5)
94if (DecodeFromUtfChar(span[i..], out Rune rune, out elemsConsumed) != OperationStatus.Done) 100if (!Rune.IsWhiteSpace(rune)) 111internal static OperationStatus DecodeFromUtfChar<TChar>(ReadOnlySpan<TChar> span, out Rune result, out int elemsConsumed) 115? Rune.DecodeFromUtf8(Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<byte>>(span), out result, out elemsConsumed) 116: Rune.DecodeFromUtf16(Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<char>>(span), out result, out elemsConsumed);
System\Numerics\Complex.Generic.cs (2)
1970if (Number.DecodeFromUtfChar(text[(semicolon + 1)..], out Rune rune, out int elemsConsumed) == OperationStatus.Done) 1972if (Rune.IsWhiteSpace(rune))
System.Text.Encodings.Web (33)
System\Text\Encodings\Web\AsciiByteMap.cs (1)
34internal readonly bool TryLookup(Rune key, out byte value)
System\Text\Encodings\Web\DefaultHtmlEncoder.cs (2)
67internal override int EncodeUtf8(Rune value, Span<byte> destination) 133internal override int EncodeUtf16(Rune value, Span<char> destination)
System\Text\Encodings\Web\DefaultJavaScriptEncoder.cs (4)
113internal override int EncodeUtf8(Rune value, Span<byte> destination) 129static int TryEncodeScalarAsHex(object @this, Rune value, Span<byte> destination) 164internal override int EncodeUtf16(Rune value, Span<char> destination) 180static int TryEncodeScalarAsHex(object @this, Rune value, Span<char> destination)
System\Text\Encodings\Web\DefaultUrlEncoder.cs (2)
142internal override int EncodeUtf8(Rune value, Span<byte> destination) 171internal override int EncodeUtf16(Rune value, Span<char> destination)
System\Text\Encodings\Web\OptimizedInboxTextEncoder.Ascii.cs (2)
46Rune rune = new Rune(i); // guaranteed to succeed 47if (!Rune.IsControl(rune) && allowedCodePointsBmp.IsCharAllowed((char)i))
System\Text\Encodings\Web\OptimizedInboxTextEncoder.cs (10)
187if (!Rune.TryCreate(thisChar, out Rune scalarValue)) 192if (Rune.TryCreate(thisChar, source[srcIdxTemp], out scalarValue)) 202scalarValue = Rune.ReplacementChar; // fallback char 304OperationStatus runeDecodeStatus = Rune.DecodeFromUtf8(source.Slice(srcIdx), out Rune scalarValue, out int bytesConsumedJustNow); 312Debug.Assert(scalarValue == Rune.ReplacementChar); // DecodeFromUtfXX should've set replacement character on failure 383OperationStatus opStatus = Rune.DecodeFromUtf8(data, out Rune scalarValue, out int bytesConsumed); 450public bool IsScalarValueAllowed(Rune value)
System\Text\Encodings\Web\ScalarEscaperBase.cs (2)
11internal abstract int EncodeUtf16(Rune value, Span<char> destination); 12internal abstract int EncodeUtf8(Rune value, Span<byte> destination);
System\Text\Encodings\Web\TextEncoder.cs (10)
67if (Rune.DecodeFromUtf16(utf16ScratchBuffer, out Rune nextScalarValue, out int scalarUtf16CodeUnitCount) != OperationStatus.Done) 337OperationStatus opStatus = Rune.DecodeFromUtf8(utf8Source, out Rune scalarValue, out int bytesConsumedJustNow); 345Debug.Assert(scalarValue == Rune.ReplacementChar); // DecodeFromUtf8 should've performed substitution 459OperationStatus status = Rune.DecodeFromUtf16(source, out Rune scalarValue, out int charsConsumedJustNow); 467Debug.Assert(scalarValue == Rune.ReplacementChar); // should be replacement char 565OperationStatus opStatus = Rune.DecodeFromUtf8(utf8Text, out Rune scalarValue, out int bytesConsumed);
System.Text.Json (3)
System\Text\Json\Reader\JsonReaderHelper.Unescaping.cs (1)
487var rune = new Rune(scalar);
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.StringSegment.cs (2)
74switch (Rune.DecodeFromUtf16(combinedBuffer, out _, out int charsConsumed)) 242switch (Rune.DecodeFromUtf8(combinedBuffer, out _, out int bytesConsumed))
System.Web.HttpUtility (2)
System\Web\Util\HttpEncoder.cs (2)
689chars[i] = (char)Rune.ReplacementChar.Value; 699chars[i] = (char)Rune.ReplacementChar.Value;