Table of Contents

Method InvokeWithUTF8Span

Namespace
Alternet.Skia
Assembly
Alternet.UI.Common.dll

InvokeWithUTF8Span(ReadOnlySpan<char>, Action<nint, int>)

Converts the specified UTF-16 character span to UTF-8 and invokes the provided action with a pointer to the UTF-8 data and its length.

public static void InvokeWithUTF8Span(ReadOnlySpan<char> input, Action<nint, int> action)

Parameters

input ReadOnlySpan<char>

The UTF-16 character span to be converted to UTF-8. If the span is empty, the action is invoked with a null pointer and a length of 0.

action Action<nint, int>

The action to invoke with the UTF-8 data. The action receives a pointer to the UTF-8-encoded bytes and the number of bytes in the UTF-8 data. The pointer is valid only for the duration of the action's execution.

Remarks

This method uses stack allocation for small UTF-8 buffers and heap allocation for larger ones. Callers should ensure that the action does not store or use the pointer outside the scope of the action.