Encodes a string using a custom alphabet by dividing by the base and handling leading zeroes.

getBaseXCodec for a more detailed description.