Implement bzip2's run-length encoding
CJam, 50 48 bytes
l_{}`:T&amp;1${_T#)_(@a?)+}%{(\2b)*}%@e`{(2b1&gt;Tf=}%?

Thanks for Dennis for saving 2 bytes.
Try it online.
Explanation
l_              e# Read and duplicate input.
{}`:T           e# T = &quot;{}&quot;
&amp;               e# If the input has '{ or '}:
    1$          e# Input.
    {           e# For each character:
        _T#)    e# If it is '{ or '}:
            _(  e# Return 0 for '{ or 1 for '}.
            @a  e# Otherwise, convert the character itself to an array (string).
        ?
        )+      e# If it is a number, increment and append to the previous array.
                e# If it is a string with at least 1 character, do nothing.
    }%
    {(\         e# For each character and bijective base 2 number:
        2b)*    e# Repeat the character 1 + that many times.
    }%
                e# Else:
    @           e# Input.
    e`          e# Run-length encoding.
    {(          e# For each character and length:
        2b1&gt;    e# Convert the length to base 2 and remove the first bit.
        Tf=     e# Map 0 to '{ and 1 to '}.
    }%
?               e# End if.