5 ms·
UUIDs are 128-bits, not characters. The string representation is just for humans.
by chewbacha 3y ago
UUIDs are 128-bits, not characters. The string representation is just for humans.
- shepherdjerred 3y agoI think the parent is saying that we can make UUIDs more human-readable by displaying the underlying 128 bits with a larger set of characters.
- dragonwriter 3y agoWe could make the string representation more compact with more characters, but I’m not sure compactness and readability are the same, especially any compactness that takes more than the ASCII character set (sure, just the hexadecimal digits may be fewer than ideal.)
- chungy 3y agoBase58 and Base64 exist in pure-ASCII space. Expanding into non-ASCII characters would probably just be confusing.
- treve 3y agoI think it's a fair question, because yes you should store them as numbers, but they are still often sent in text formats and urls. Wanting a shorter representation is reasonable. The easiest is probably to just base64 the binary representation of the 128 bit number, which results in a 128/6=22 character string, which is a bit smaller. If glyph-length and not byte-length is more important you could go even smaller but I'm less sure if that's a good idea.
- gabereiser 3y agoThis is the way. Look not at the characters but at the hex.