Skip to content

Instantly share code, notes, and snippets.

@Drawaes
Created January 26, 2020 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Drawaes/07670e15e5f22b672eaa15afe57488e2 to your computer and use it in GitHub Desktop.
Save Drawaes/07670e15e5f22b672eaa15afe57488e2 to your computer and use it in GitHub Desktop.
private static ReadOnlySpan<byte> NewLine => new byte[] { (byte)'\r', (byte)'\n' };
static void Test()
{
//const ReadOnlySpan<byte> eol = new byte[] { 13, 10 };
var data = new byte[]{72,84,84,80,47,49,46,49,32,50, 48, 48, 32, 79, 75, 13, 10
, 67, 111, 110, 116, 101, 110, 116, 45, 84, 121, 112, 101, 58, 32, 116, 101, 120, 116
, 47, 112, 108, 97, 105, 110, 59, 32, 99, 104, 97, 114, 115, 101, 116, 61, 117, 116, 102
, 45, 56, 13 };
var ros = new ReadOnlySequence<byte>(data);
var reader = new SequenceReader<byte>(ros);
var header1 = reader.TryReadTo(out ReadOnlySpan<byte> version, (byte)' ');
var header2 = reader.TryReadTo(out ReadOnlySpan<byte> status, (byte)' ');
var newLine = reader.TryReadTo(out ReadOnlySpan<byte> line, NewLine);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment