Closed LuminousXLB closed 4 years ago
That's an interesting idea! I could see a feature like that making sense but it should probably be optional.
there's also the question on how to deal with different alphabets because all the fixes may not apply to all of them
I feel like the way to go on this would be to have an argument like fix_lookalike
, and if it's true to apply some regexes or if statements to the alphabet. That way if you don't cover all cases they can just not use it.
I appreciate the idea of fix_lookalike
.
And for the implementation, it might be better to give a map table, which maps '1' and 'l' to the same integer. It might be something like this
With the changes proposed in #53 adding a pass to modify the map with these fixes should be simple enough.
so there are a couple of character sets 1l
oO0
that can be fixed as long as only one of the elements are in the alphabet. Any other characters that could get fixed?
Il
as well. Maybe 4A
, depending on font?
For the bitcoin style, here's a reference
123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
Or, more simply, it is a set of lowercase and capital letters and numbers without the four (0, O, l, I) just mentioned.
That's to say 0
, O
should be mapped to o
and I
, l
should be mapped to 1
.
It seems that RIPPLE_ALPHABET
and BITCOIN_ALPHABET
use the same charset in a different order, thus the same mapping rule should be applicable.,
In [6]: RIPPLE_ALPHABET = b'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'
In [7]: BITCOIN_ALPHABET = b'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
In [8]: RIPPLE_SORTED = bytes(sorted(RIPPLE_ALPHABET))
In [9]: RIPPLE_SORTED == BITCOIN_ALPHABET
Out[9]: True
Shall we merge #53 firstly and then we can modify on it?
@LuminousXLB yeah, that seems to be the best way
Would you like to add some fault tolerance such as automatically change
l
to1
?