Table of Contents

Method MarshalString

Namespace
Ubiquity.NET.InteropHelpers
Assembly
Ubiquity.NET.InteropHelpers.dll

MarshalString(Encoding, ReadOnlySpan<byte>)

Provides conversion of a span of bytes to managed code

public static string? MarshalString(this Encoding self, ReadOnlySpan<byte> span)

Parameters

self Encoding

The encoding to use for conversion

span ReadOnlySpan<byte>

Input span to convert with or without a null terminator.

Returns

string

string containing the decoded characters from the input span

Remarks

If the input span is empty, then this returns null.

Exceptions

ArgumentNullException

self is null

MarshalString(Encoding, byte*)

Provides conversion of the native bytes to managed code

public static string? MarshalString(this Encoding self, byte* nativeStringPtr)

Parameters

self Encoding

The encoding to use for conversion

nativeStringPtr byte*

pointer to the native code string to convert

Returns

string

string containing the decoded characters from the input nativeStringPtr

Remarks

If the input nativeStringPtr is null, then this returns null.

Exceptions

ArgumentNullException

self is null