internal static ReadOnlySpan <byte> JT808DeEscape(ReadOnlySpan <byte> buf) { var bytes = JT808ArrayPool.Rent(buf.Length); try { int i = 0; int offset = 0; int len = 0 + buf.Length; while (i < len) { if (buf[i] == 0x7d) { if (len > i + 1) { if (buf[i + 1] == 0x01) { bytes[offset++] = 0x7d; i++; } else if (buf[i + 1] == 0x02) { bytes[offset++] = 0x7e; i++; } else { bytes[offset++] = buf[i]; } } } else { bytes[offset++] = buf[i]; } i++; } return(bytes.AsSpan(0, offset).ToArray()); } finally { JT808ArrayPool.Return(bytes); } }
public void Dispose() { JT808ArrayPool.Return(escapeBytesPoll); }