Hi,
I'm trying to write a decoder for Yenc, the compression algorithm is as follows:
So in terms of compression my pseudo code looks something like this:Code:1. Fetch a character from the input stream. 2. Increment the character's ASCII value by 42, modulo 256 3. If the result is a critical character (as defined in the previous section), write the escape character to the output stream and increment character's ASCII value by 64, modulo 256. 4. Output the character to the output stream. 5. Repeat from start.
Now for reversal and getting the orignal ASCII code out I have no idea how to approach it as i don't really understand modulo maths, could anyone lend a hand with some reversal pseudo code?Code:Result = (ASCII+42) % 256 If Result == CriticalValue WriteOut(CriticalValue) Result = (CriticalValue + 64) % 256 WriteOut(Result)
Thanks alot for any help,.
Jack



LinkBack URL
About LinkBacks



