You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-12Lines changed: 18 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,7 +92,7 @@ From the community!
92
92
93
93
Below is the current specification of ULID as implemented in this repository.
94
94
95
-
*Note: the binary format has not been implemented.*
95
+
*Note: the binary format has not been implemented in JavaScript as of yet.*
96
96
97
97
```
98
98
01AN4Z07BY 79KA1307SR9X4MV3
@@ -117,14 +117,30 @@ Below is the current specification of ULID as implemented in this repository.
117
117
118
118
The left-most character must be sorted first, and the right-most character sorted last (lexical order). The default ASCII character set must be used. Within the same millisecond, sort order is not guaranteed
119
119
120
-
### Encoding
120
+
### Canonical String Representation
121
+
122
+
```
123
+
ttttttttttrrrrrrrrrrrrrrrr
124
+
125
+
where
126
+
t is Timestamp (10 characters)
127
+
r is Randomness (16 characters)
128
+
```
129
+
130
+
#### Encoding
121
131
122
132
Crockford's Base32 is used as shown. This alphabet excludes the letters I, L, O, and U to avoid confusion and abuse.
123
133
124
134
```
125
135
0123456789ABCDEFGHJKMNPQRSTVWXYZ
126
136
```
127
137
138
+
#### Overflow Errors when Parsing Base32 Strings
139
+
140
+
Technically, a 26 character Base32 encoded string can contain 130 bits of information, whereas a ULID must only contain 128 bits. Therefore, the largest valid ULID encoded in Base32 is `7ZZZZZZZZZZZZZZZZZZZZZZZZZ`, which corresponds to an epoch time of `281474976710655`.
141
+
142
+
Any attempt to decode or encode a ULID larger than this should be rejected by all implementations, to prevent overflow bugs.
143
+
128
144
### Binary Layout and Byte Order
129
145
130
146
The components are encoded as 16 octets. Each component is encoded with the Most Significant Byte first (network byte order).
@@ -143,16 +159,6 @@ The components are encoded as 16 octets. Each component is encoded with the Most
0 commit comments