Burrow-Wheeler encoding implementation.