I'm trying to map a 12 digit number into a fixed width file. For a number of reasons, it must be compressed in such a way that it is guaranteed to be less than or equal to 9 characters (alpha numeric is fine). My first thought was a change of base, but I can't find an equation which gives an upper bound the number of characters needed for a given base.
For example, transforming into base 32
123456789101 -> 3IV9I6JD
Which is 8 digits. How to find a basis which is guaranteed to need 9 or less characters to represent a 12 digits number?