You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[API Proposal]: Add static methods System.Text.Rune.Parse and System.Text.Rune.TryParse to System.Text.Rune (without IFormatProvider? provider & not Explicit Interface Implementations) #129463
char has the APIs char.Parse and char.TryParse but it's inconsistent that Rune doesn't have the same APIs as char.
They are useful for generating Rune values from strings representing single code points in languages like PowerShell (and VB.NET) where char type (literal expression) isn't particularly common and for creating unit tests where Fine Rune values are created from string literals embedded in InlineData.
stringstrToCast="😀";// supplementary character (can't be stored in `char`)if(!Rune.TryParse(strToCast,outRuner)){Console.Error.WriteLine($"Cast failed from \"{strToCast}\" to Rune in programming language FooBarBaz");}returnr;
changed the title [-][API Proposal]: Add static methods `System.Text.Rune.Parse` and `System.Text.Rune.TryParse` to `System.Text.Rune`[/-][+][API Proposal]: Add static methods `System.Text.Rune.Parse` and `System.Text.Rune.TryParse` to `System.Text.Rune` (without `IFormatProvider? provider`)[/+]on Jun 16, 2026
changed the title [-][API Proposal]: Add static methods `System.Text.Rune.Parse` and `System.Text.Rune.TryParse` to `System.Text.Rune` (without `IFormatProvider? provider`)[/-][+][API Proposal]: Add static methods `System.Text.Rune.Parse` and `System.Text.Rune.TryParse` to `System.Text.Rune` (without `IFormatProvider? provider` & not Explicit Interface Implementations)[/+]on Jun 16, 2026
We're not interesting in providing such a publicly exposed parse API. The logic and handling required is trivial here and can be rolled in your own helper API if you want something reusable.
You should use the decode APIs and check the result if you need to handle edges like more data existing.
Activity
dotnet-policy-service commentedon Jun 16, 2026
Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.
MihuBot commentedon Jun 16, 2026
I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):
MihaZupan commentedon Jun 16, 2026
You can also use
TryGetRuneAtorDecodeFromUtf16that make your example much simpler.E.g.
MihaZupan commentedon Jun 16, 2026
Note that the proposal is only adding explicitly implemented interface methods, so you wouldn't see them show up as
Rune.TryParsetats-u commentedon Jun 16, 2026
Oh no, #60231 takes the extra parameter
IFormatProvider? provider.[-][API Proposal]: Add static methods `System.Text.Rune.Parse` and `System.Text.Rune.TryParse` to `System.Text.Rune`[/-][+][API Proposal]: Add static methods `System.Text.Rune.Parse` and `System.Text.Rune.TryParse` to `System.Text.Rune` (without `IFormatProvider? provider`)[/+]tats-u commentedon Jun 16, 2026
This returns unexpected results for strings consisting of multiple code points.
This does not make
rU+0000 NUL (default) for strings consisting of multiple code points.In other words, neither of the examples you provided is production-quality code.
[-][API Proposal]: Add static methods `System.Text.Rune.Parse` and `System.Text.Rune.TryParse` to `System.Text.Rune` (without `IFormatProvider? provider`)[/-][+][API Proposal]: Add static methods `System.Text.Rune.Parse` and `System.Text.Rune.TryParse` to `System.Text.Rune` (without `IFormatProvider? provider` & not Explicit Interface Implementations)[/+]tannergooding commentedon Jun 24, 2026
We're not interesting in providing such a publicly exposed parse API. The logic and handling required is trivial here and can be rolled in your own helper API if you want something reusable.
You should use the decode APIs and check the result if you need to handle edges like more data existing.