mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 13:08:24 +01:00
SOURCE DUMP v1
This commit is contained in:
parent
bd62d51ec9
commit
fb20299e9d
1 changed files with 768360 additions and 0 deletions
25
brutal.strings/Brutal.Strings/Unicode/Utf16.cs
Normal file
25
brutal.strings/Brutal.Strings/Unicode/Utf16.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Brutal.Strings;
|
||||
|
||||
/// <summary>UTF-16 / char-span counterpart of <see cref="Utf8"/>. Minimal surface for now.</summary>
|
||||
public static partial class Utf16
|
||||
{
|
||||
/// <summary>
|
||||
/// Count the number of chars in a null-terminated char array.
|
||||
/// </summary>
|
||||
[Pure]
|
||||
public static unsafe int GetCharCount(Ptr<Char16> chars)
|
||||
{
|
||||
return MemoryMarshal.CreateReadOnlySpanFromNullTerminated(chars).Length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a null-terminated char array to a <see cref="Span{T}"/> containing the chars up to the null terminator.
|
||||
/// </summary>
|
||||
[Pure]
|
||||
public static unsafe String16View GetNullTerminatedSpan(Ptr<Char16> chars)
|
||||
{
|
||||
return MemoryMarshal.CreateReadOnlySpanFromNullTerminated(chars);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue