def cut_prefix(value, prefix):
    """Removes the leading `prefix` if exists, else return `value`
    unchanged.

    """
    from xotl.tools.future.codecs import safe_encode, safe_decode
    if isinstance(value, str) and isinstance(prefix, bytes):
        prefix = safe_decode(prefix)
    elif isinstance(value, bytes) and isinstance(prefix, str):
        prefix = safe_encode(prefix)
    return value[len(prefix):] if value.startswith(prefix) else value
