mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-12 11:46:01 -05:00
21 lines
683 B
C#
21 lines
683 B
C#
using System.Runtime.CompilerServices;
|
|
|
|
namespace NHSE.Core
|
|
{
|
|
public static partial class StringUtil
|
|
{
|
|
/// <summary>
|
|
/// Trims a string at the first instance of a 0x0000 terminator.
|
|
/// </summary>
|
|
/// <param name="input">String to trim.</param>
|
|
/// <returns>Trimmed string.</returns>
|
|
public static string TrimFromZero(string input) => TrimFromFirst(input, '\0');
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
private static string TrimFromFirst(string input, char c)
|
|
{
|
|
int index = input.IndexOf(c);
|
|
return index < 0 ? input : input.Substring(0, index);
|
|
}
|
|
}
|
|
} |