def _swap_illegal_chars(byte_seq, seq_map):
    """Replace illegal byte sequences with legal ones"""
    for s, r in seq_map:
        _byte_seq = byte_seq
        while _byte_seq.find(s) > 1:
            _byte_seq = _byte_seq.replace(s, r)
    swapped_byte_seq = _byte_seq
    return swapped_byte_seq
