Talk:Consistent overhead byte stuffing

From Rosetta Code

Draft task graduation

"If 0x00 does not appear within the next 254 bytes after a milestone the algorithm must emit an extra milestone at the 255th byte."

I'm too neuron-deprived from completing the task in Insitux to determine if this sentence is correct. Until I or somebody else comes along and verifies it / corrects it the task should remain a draft. --Phunanon (talk) 02:16, 23 September 2023 (UTC)

All examples should have output that shows/proves they work correctly. We all know the consequences of an "It compiles, I'm finished" attitude. The Wikipedia examples/tests cover that milestone thing, I think. However, I'm not at all sure what "error-check functionality" or "non-zero marker" actually mean or what they might look like. --Petelomax (talk) 15:16, 24 September 2023 (UTC)
Well, I guess you can check that the unencoded or encoded data consists entirely of bytes and the latter ends with a marker but I've no idea how one could deal with a non-zero marker. If say the marker were 0x02 how could you indicate a length of 2 to the next milestone when encoding? --PureFox (talk) 16:03, 24 September 2023 (UTC)
That's certainly the challenge of a non-zero marker, PureFox! You'd have to count around the chosen marker (with 0x02 as the example 0 -> 1, 1 -> 2, 3 -> 3, 4 -> 4, etc I think), which is why it's so convenient to just use 0x00. As for error checking, that would consist of safely failing if the marker is encountered unexpectedly. --Phunanon (talk) 20:42, 26 September 2023 (UTC)
See "The Bonus Tasks" for a method that I think does a non-zero packet marker simply.--Nigel Galloway (talk) 14:06, 28 September 2023 (UTC)
I'll include some formatted output in Insitux to help with that good-output trend. I toyed with including the test cases from Wikipedia verbatim but felt the task would be too long and I don't know how to do the nice formatting Wikipedia has. I'll flesh out the bonus tasks, thank you for the input! --Phunanon (talk) 20:42, 26 September 2023 (UTC)

The Bonus Tasks

This code would be sitting at a layer above the transmission layer, which is separating bytes received into packets using a marker which is guaranteed not to appear in the packet. Therefor the error condition "an unexpected instance of the chosen marker" can not occur, the lower layer would have considered it to be two packets. The error that could occur is that a next marker count could exceed the end of a packet. "Support a non-zero marker" can be achieved by the same code as the zero-marker and then XORing each byte in the output stream with the non-zero marker. The receiver reversing same before decoding.--Nigel Galloway (talk) 14:06, 28 September 2023 (UTC)

I'll edit the error-detect bonus task to reflect this, thanks. --Phunanon (talk) 21:54, 28 September 2023 (UTC)

Wikipedia C entry

The C entry is from the Wikipedia article on COBS verbatim. Is this accepted practice for RC? --Phunanon (talk) 22:03, 28 September 2023 (UTC)

Well, it's something which is occasionally done though whenever you try to edit an RC page, there's a note which says:
"You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!"
So, if I were you, I'd make it clear that you didn't write the C entry yourself but have copied it from Wikipedia and refer to the Wikipedia license terms. I think such code would be classed as a 'similar free resource' even though, strictly speaking, it's not public domain. --PureFox (talk) 09:18, 29 September 2023 (UTC)