Created
March 29, 2020 02:32
-
-
Save nramsbottom/56ed92ae99ab3a8590550c34d3070ea2 to your computer and use it in GitHub Desktop.
Read ASCII zero terminated string from byte array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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