mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 04:58:24 +01:00
first
This commit is contained in:
parent
bd62d51ec9
commit
b578433e37
1 changed files with 784842 additions and 0 deletions
23
Brutal.OpenAl/Manual/StringUtils.cs
Normal file
23
Brutal.OpenAl/Manual/StringUtils.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using Brutal.Strings;
|
||||
|
||||
namespace Brutal.OpenAlApi;
|
||||
|
||||
internal static unsafe class StringUtils
|
||||
{
|
||||
internal static string? Utf8ToString(byte* p) => p is null ? null : Utf8.GetString(p);
|
||||
|
||||
internal static string[] Utf8ListToStrings(byte* p)
|
||||
{
|
||||
if (p is null)
|
||||
return [];
|
||||
|
||||
var result = new List<string>();
|
||||
while (*p != 0)
|
||||
{
|
||||
var entry = Utf8.GetNullTerminatedSpan(p);
|
||||
result.Add(Utf8.GetString(entry));
|
||||
p += entry.Length + 1; // step over this entry's terminator
|
||||
}
|
||||
return [.. result];
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue