Skip to content

Commit 7320199

Browse files
committed
Better trim
1 parent 6f30a4d commit 7320199

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Source/EndianBinaryReader.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,13 @@ public string ReadString_Count_TrimNullTerminators(int charCount)
541541
{
542542
char[] chars = new char[charCount];
543543
ReadChars(chars);
544-
EndianBinaryPrimitives.TrimNullTerminators(ref chars);
544+
545+
// Trim '\0's
546+
int i = Array.IndexOf(chars, '\0');
547+
if (i != -1)
548+
{
549+
return new string(chars, 0, i);
550+
}
545551
return new string(chars);
546552
}
547553
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]

0 commit comments

Comments
 (0)