Skip to content

Instantly share code, notes, and snippets.

@nramsbottom
Created March 29, 2020 02:32
Show Gist options
  • Save nramsbottom/56ed92ae99ab3a8590550c34d3070ea2 to your computer and use it in GitHub Desktop.
Save nramsbottom/56ed92ae99ab3a8590550c34d3070ea2 to your computer and use it in GitHub Desktop.
Read ASCII zero terminated string from byte array
private string ReadAsciiZeroString(byte[] bytes)
{
for (int n = 0; n < bytes.Length; n++)
{
if (bytes[n] == '\0')
return System.Text.Encoding.ASCII.GetString(bytes, 0, n);
}
return string.Empty;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment