Skip to content

Commit fb75b2a

Browse files
committed
Update package version and add byte string append method
Updated the `PackageVersion` in `Hexa.NET.Utilities.csproj` from `2.2.2` to `2.2.3`. Added a new method `Append(byte* cstr)` in `StrBuilder.cs` to append null-terminated byte strings to the buffer, with null handling and index updating.
1 parent fb60a0f commit fb75b2a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Hexa.NET.Utilities/Hexa.NET.Utilities.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<PropertyGroup>
2020
<PackageId>Hexa.NET.Utilities</PackageId>
2121
<AssemblyVersion>1.0.0</AssemblyVersion>
22-
<PackageVersion>2.2.2</PackageVersion>
22+
<PackageVersion>2.2.3</PackageVersion>
2323
<Authors>Juna</Authors>
2424
<AssemblyName>Hexa.NET.Utilities</AssemblyName>
2525
<PackageProjectUrl>https://github.com/HexaEngine/Hexa.NET.Utilities</PackageProjectUrl>

Hexa.NET.Utilities/Text/StrBuilder.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,22 @@ public void Append(ReadOnlySpan<byte> text)
4242
Index += written;
4343
}
4444

45+
public void Append(byte* cstr)
46+
{
47+
if (cstr == null) return;
48+
49+
byte* start = Buffer + Index;
50+
byte* ptr = start;
51+
byte* end = Buffer + Count;
52+
53+
while (*cstr != '\0' && ptr != end)
54+
{
55+
*ptr++ = *cstr++;
56+
}
57+
int written = (int)(ptr - start);
58+
Index += written;
59+
}
60+
4561
public void Append(char c)
4662
{
4763
Index += Utf8Formatter.ConvertUtf16ToUtf8(c, Buffer + Index, Count - Index);

0 commit comments

Comments
 (0)