前陣子寫的「UUID 的 UX」考慮到了人眼會把 0Oo
以及 1IiLl
看錯的問題,這篇則是更激進的想辦法去避免類似的問題:「Understanding and avoiding visually ambiguous characters in IDs」,對應的討論可以在「Understanding and avoiding visually ambiguous characters in IDs (gajus.com)」這邊看到。
作者有提到,這是用在人類需要寫下或是溝通時,避免錯誤的發生:
Any time that the ID might need to be communicated verbally or written down[.]
這就不只是前面提到的 0Oo
與 1IiLl
問題了,包括看起來有機會誤會的字,像是 2Z
以及 8B
這種也要避開。
如果是大小寫都放進去的話是 53 個字可以用,但如果希望大小寫意思一樣的話就只剩下 22 個字可以用了:
Assuming that you are going with case sensitivity, you have 53 characters to choose from (adjusted for visually ambiguous characters). On the other hand, if you decide to make your IDs case-insensitive, you have only 22 characters to choose from.
他給出了這 22 個字:
[ "a", "b", "c", "d", "e", "f", "h", "i", "j", "k", "m", "n", "o", "p", "r", "s", "t", "w", "x", "y", "3", "4" ]
後續還提到 rn
與 m
,以及 vv
與 w
的相似問題,不過這邊的 generator 就更難搞了...
搞到這樣,乾脆用數字就好?使用者的 UX 也比較好?