-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Closed
Copy link
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Buffers
Milestone
Description
Background and motivation
As I started looking into #73500 I realized Utf8Formatter/Utf8Parser are missing UInt128/Int128 overloads and therefore we need to unnecessarily do UTF16 <--> UTF8 conversion.
cc: @tannergooding
API Proposal
namespace System.Buffers.Text;
public static partial class Utf8Formatter
{
public static bool TryFormat(UInt128 value, System.Span<byte> destination, out int bytesWritten, System.Buffers.StandardFormat format = default(System.Buffers.StandardFormat)) { throw null; }
public static bool TryFormat(Int128 value, System.Span<byte> destination, out int bytesWritten, System.Buffers.StandardFormat format = default(System.Buffers.StandardFormat)) { throw null; }
}
public static partial class Utf8Parser
{
public static bool TryParse(System.ReadOnlySpan<byte> source, out UInt128 value, out int bytesConsumed, char standardFormat = '\0') { throw null; }
public static bool TryParse(System.ReadOnlySpan<byte> source, out Int128 value, out int bytesConsumed, char standardFormat = '\0') { throw null; }
}API Usage
if (Utf8Parser.TryParse(someUtf8Span, out UInt128 value, out int bytesConsumed) && someUtf8Span.Length == bytesConsumed)
{
Console.WriteLine($"Successfully parsed UInt128 value: {value}");
}
UInt128 value = ...;
bool result = Utf8Formatter.TryFormat(value, utf8Output, out int bytesWritten);
// and similar for Int128Alternative Designs
No response
Risks
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Buffers