I was trying to come up with a string compression algorithm for plaintext, e.g.
AAAAAAAABB -> A@8BB
where n symbols y are written out like
y@n
The problem is: what if I need to compress the string "A@8" ? That would confuse the decompression algorithm into thinking that the original input was "AAAAAAAA" instead of just "A@8".
How can I solve this problem? I was thinking of using a "marker" character instead of the @, but what if I wanted the algorithm to work with binary data? There is no marker character that can be used in that case I suppose