Table of Contents

Class UTF16

Namespace
SimdUnicode
Assembly
SimdUnicode.dll
public static class UTF16
Inheritance
UTF16
Inherited Members

Fields

ReplacementCharacter

The replacement character U+FFFD.

Methods

GetPointerToFirstInvalidChar(char*, int)

Given an input buffer pInputBuffer of inputLength UTF-16 code units, returns a pointer to the first lone (unpaired) surrogate.

GetPointerToFirstInvalidCharArm64(char*, int)
GetPointerToFirstInvalidCharAvx2(char*, int)
GetPointerToFirstInvalidCharAvx512(char*, int)
GetPointerToFirstInvalidCharFallback(char*, int)

Portable version used when no SIMD kernel applies (no ARM64 NEON, AVX-512, AVX2 or SSE4.1): we rely on the runtime's vectorized IndexOfAnyInRange to skip everything that is not a surrogate.

GetPointerToFirstInvalidCharScalar(char*, int)
GetPointerToFirstInvalidCharSse(char*, int)
IsWellFormed(ReadOnlySpan<char>)

Returns true if input contains no lone surrogate.

ToWellFormed(char*, int, char*)

Copies inputLength UTF-16 code units from pInputBuffer to pOutputBuffer, replacing every lone surrogate by U+FFFD. The two buffers must either be identical (in-place operation) or not overlap.

ToWellFormed(ReadOnlySpan<char>, Span<char>)

Copies source to destination, replacing every lone surrogate by U+FFFD. The spans must either start at the same address (in-place operation) or not overlap.

ToWellFormed(string)

Returns a well-formed copy of input where every lone surrogate is replaced by U+FFFD. If input is already well formed, it is returned as is (no allocation).

ToWellFormedArm64(char*, int, char*)
ToWellFormedAvx2(char*, int, char*)
ToWellFormedAvx512(char*, int, char*)
ToWellFormedFallback(char*, int, char*)

Portable version used when no SIMD kernel applies (see GetPointerToFirstInvalidCharFallback(char*, int)).

ToWellFormedScalar(char*, int, char*)

Straightforward scalar version, a port of simdutf's scalar::utf16::to_well_formed_utf16.

ToWellFormedSse(char*, int, char*)