Talk:Run-length encoding: Difference between revisions

From Rosetta Code
Content added Content deleted
(alternate encoding)
(the rle i knew)
Line 4: Line 4:
* Run code has high bit set, remaining 7 bits are run length-1.
* Run code has high bit set, remaining 7 bits are run length-1.
* Bytes in stream with high bit set are always encoded as a run, perhaps with a length of only one.
* Bytes in stream with high bit set are always encoded as a run, perhaps with a length of only one.

: The RLE I knew was: high bit says if that byte says how many "literal bytes" follow, or if the next byte must be repeated according to the value of the previous byte (clearing the high bit); so, e.g. ABCD would be encoded as, just to say, bytes 84 "A" "B" "C" "D"; of course, this way the maximum number of repetition (or longest literal sequence) is 128 (0 means 128). I've settled down to the task specification, but tried to create more usable examples... --[[User:ShinTakezou|ShinTakezou]] 23:08, 24 April 2009 (UTC)

Revision as of 23:08, 24 April 2009

"The output can be anything." might be too open-ended. I would prefer it if all the solutions did it the same way, or something. --76.167.241.45 18:32, 24 April 2009 (UTC)

I would prefer this task to use a run length encoding which will work at least on all ASCII characters. The current encoding can't represent [0-9]. A more flexible encoding is implemented here. --IanOsgood 19:27, 24 April 2009 (UTC)

  • Run code has high bit set, remaining 7 bits are run length-1.
  • Bytes in stream with high bit set are always encoded as a run, perhaps with a length of only one.
The RLE I knew was: high bit says if that byte says how many "literal bytes" follow, or if the next byte must be repeated according to the value of the previous byte (clearing the high bit); so, e.g. ABCD would be encoded as, just to say, bytes 84 "A" "B" "C" "D"; of course, this way the maximum number of repetition (or longest literal sequence) is 128 (0 means 128). I've settled down to the task specification, but tried to create more usable examples... --ShinTakezou 23:08, 24 April 2009 (UTC)