using System.Diagnostics.Contracts; namespace Brutal.Strings; /// UTF-16 / char-span counterpart of . Minimal surface for now. public static partial class Utf16 { /// /// Count the number of chars in a null-terminated char array. /// [Pure] public static unsafe int GetCharCount(Ptr chars) { return MemoryMarshal.CreateReadOnlySpanFromNullTerminated(chars).Length; } /// /// Convert a null-terminated char array to a containing the chars up to the null terminator. /// [Pure] public static unsafe String16View GetNullTerminatedSpan(Ptr chars) { return MemoryMarshal.CreateReadOnlySpanFromNullTerminated(chars); } }