Lately, I have been entering a number of coupon codes on the web, and have found them to be infuriatingly lacking in one respect: the character set used for the codes is not easy to type.
I'm sure we have all questioned at one point if a character in the code was supposed to be a
0 (zero) or
O (upper-case letter O), or a
I (upper-case letter I), or
l (lower-case letter L). Usually you just pick one, and usually you get it wrong the first time.
I find it particularly strange, that Starbucks would go so far as to recognize this problem, but not actually fix it:
As a developer, there are a few increasingly dramatic ways to deal with this.
Solution 1: Deal with ambiguity
If you are worried about the distinction between
8B, or any other combinations, treat them as the same character!
This is what Base32 does. It will standardize on one of the characters above (say the digits
018), and omit the ones are too similar (in this case
When you receive input from the user, map the omitted characters to the canonical ones (e.g. replace the letter O with the digit zero). This way, even if the user can't figure it out, it doesn't matter anyways.
Solution 2: Remove all ambiguity
Base32 still leaves characters which seem like they may be ambiguous, even if underneath they can't be. For users with a little experience with this, they will still stop to question what they are doing.
Ergo, you can take it a step further and completely remove all characters that could be perceived as ambiguous (e.g. all of
After all, you don't actually need your alphabet size to be a power of two. It is easy enough to convert into arbitrary bases, and you don't need it to be particularly fast either (since this is often coinciding with user input).
The only caveat that I can think of is that this will likely increase the number of characters required in the code to represent the same amount of data. That is why I personally went with Base32 for the code on the back of my business cards, since I preferred the code-space with \( 32^9 \) as opposed to \( 29^9 \) (and 10 characters was too much).