Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

Encoding.ts

1,046 lines19.6 KB

1/**
2 * Encoding and decoding helpers for Base64, Base64Url, and hexadecimal text.
3 * The functions convert between strings, UTF-8 text, and `Uint8Array` bytes.
4 * Encode functions return strings directly, while decode functions return
5 * `Result.Result` so invalid input is reported as an `EncodingError` instead of
6 * being thrown.
7 *
8 * @since 4.0.0
9 */
10import * as Data from "./Data.ts"
11import { hasProperty } from "./Predicate.ts"
12import * as Result from "./Result.ts"
13​
14// -------------------------------------------------------------------------------------
15// EncodingError
16// -------------------------------------------------------------------------------------
17​
18/**
19 * Type identifier stored on `EncodingError` values and used by
20 * `isEncodingError`.
21 *
22 * **When to use**
23 *
24 * Use when implementing low-level `EncodingError`-compatible values that need
25 * to carry the runtime marker.
26 *
27 * **Details**
28 *
29 * This marker is part of the runtime representation of `EncodingError`. Prefer
30 * `isEncodingError` when narrowing unknown values.
31 *
32 * @see {@link isEncodingError} for the public guard that checks this marker
33 *
34 * @category type IDs
35 * @since 4.0.0
36 */
37export const EncodingErrorTypeId = "~effect/encoding/EncodingError" as const
38​
39/**
40 * Literal type of the `EncodingErrorTypeId` marker.
41 *
42 * **When to use**
43 *
44 * Use to type the marker carried by `EncodingError` values.
45 *
46 * @category type IDs
47 * @since 4.0.0
48 */
49export type EncodingErrorTypeId = typeof EncodingErrorTypeId
50​
51/**
52 * Error returned when an encoding or decoding operation cannot process its
53 * input.
54 *
55 * **When to use**
56 *
57 * Use when you need to handle or inspect failures from encoding or decoding
58 * operations.
59 *
60 * **Details**
61 *
62 * The error records whether the failure happened during encoding or decoding,
63 * which encoding module reported it, the original input, and a human-readable
64 * message.
65 *
66 * @see {@link isEncodingError} for checking whether a value is an EncodingError
67 * @category constructors
68 * @since 4.0.0
69 */
70export class EncodingError extends Data.TaggedError("EncodingError")<{
71 kind: "Decode" | "Encode"
72 module: string
73 input: unknown
74 message: string
75}> {
76 /**
77 * Marks this value as an encoding or decoding error for runtime guards.
78 *
79 * **When to use**
80 *
81 * Use to identify `EncodingError` instances through `isEncodingError`.
82 *
83 * @since 4.0.0
84 */
85 readonly [EncodingErrorTypeId]: EncodingErrorTypeId = EncodingErrorTypeId
87​
88/**
89 * Checks whether a value is an `EncodingError`.
90 *
91 * **When to use**
92 *
93 * Use to narrow an unknown value before handling it as an `EncodingError` from
94 * encoding or decoding code.
95 *
96 * **Details**
97 *
98 * Returns `true` when the value carries the `EncodingErrorTypeId` marker and
99 * narrows the value to `EncodingError`.
100 *
101 * @see {@link EncodingError} for the structured error produced by failed
102 * encoding and decoding operations
103 *
104 * @category guards
105 * @since 4.0.0
106 */
107export const isEncodingError = (u: unknown): u is EncodingError => hasProperty(u, EncodingErrorTypeId)
108​
109// -------------------------------------------------------------------------------------
110// Base64
111// -------------------------------------------------------------------------------------
112​
113/**
114 * Encodes the given value into a base64 (RFC4648) `string`.
115 *
116 * **When to use**
117 *
118 * Use to encode text or bytes as a standard padded Base64 string for storage or
119 * transport.
120 *
121 * **Details**
122 *
123 * String inputs are encoded as UTF-8 bytes before Base64 encoding.
124 * `Uint8Array` inputs are encoded directly. The output uses the standard
125 * RFC4648 alphabet with `=` padding.
126 *
127 * **Example** (Encoding Base64 strings and bytes)
128 *
129 * ```ts
130 * import { Encoding } from "effect"
131 *
132 * // Encode a string
133 * console.log(Encoding.encodeBase64("hello")) // "aGVsbG8="
134 *
135 * // Encode binary data
136 * const bytes = new Uint8Array([72, 101, 108, 108, 111])
137 * console.log(Encoding.encodeBase64(bytes)) // "SGVsbG8="
138 * ```
139 *
140 * @see {@link decodeBase64} for decoding standard Base64 to bytes
141 * @see {@link decodeBase64String} for decoding standard Base64 to UTF-8 text
142 * @see {@link encodeBase64Url} for URL-safe unpadded Base64 output
143 *
144 * @category encoding
145 * @since 2.0.0
146 */
147export const encodeBase64: (input: Uint8Array | string) => string = (input) =>
148 typeof input === "string" ? base64EncodeUint8Array(encoder.encode(input)) : base64EncodeUint8Array(input)
149​
150/**
151 * Decodes a base64 (RFC4648) string into bytes safely.
152 *
153 * **When to use**
154 *
155 * Use to decode a standard padded Base64 string into bytes without throwing on
156 * invalid input.
157 *
158 * **Details**
159 *
160 * Returns `Result.succeed` with a `Uint8Array` when decoding succeeds, or
161 * `Result.fail` with an `EncodingError` when the input is not valid base64.
162 *
163 * **Example** (Decoding Base64 bytes)
164 *
165 * ```ts
166 * import { Encoding, Result } from "effect"
167 *
168 * const result = Encoding.decodeBase64("SGVsbG8=")
169 * if (Result.isSuccess(result)) {
170 * console.log(Array.from(result.success)) // [72, 101, 108, 108, 111]
171 * }
172 * ```
173 *
174 * @category decoding
175 * @since 2.0.0
176 */
177export const decodeBase64 = (str: string): Result.Result<Uint8Array, EncodingError> => {
178 const stripped = stripCrlf(str)
179 const length = stripped.length
180 if (length % 4 !== 0) {
181 return Result.fail(
182 new EncodingError({
183 kind: "Decode",
184 module: "Base64",
185 input: stripped,
186 message: `Length must be a multiple of 4, but is ${length}`
187 })
188 )
189 }
190​
191 const index = stripped.indexOf("=")
192 if (index !== -1 && ((index < length - 2) || (index === length - 2 && stripped[length - 1] !== "="))) {
193 return Result.fail(
194 new EncodingError({
195 kind: "Decode",
196 module: "Base64",
197 input: stripped,
198 message: `Found a '=' character, but it is not at the end`
199 })
200 )
201 }
202​
203 try {
204 const missingOctets = stripped.endsWith("==") ? 2 : stripped.endsWith("=") ? 1 : 0
205 const result = new Uint8Array(3 * (length / 4) - missingOctets)
206 for (let i = 0, j = 0; i < length; i += 4, j += 3) {
207 const buffer = getBase64Code(stripped.charCodeAt(i)) << 18 |
208 getBase64Code(stripped.charCodeAt(i + 1)) << 12 |
209 getBase64Code(stripped.charCodeAt(i + 2)) << 6 |
210 getBase64Code(stripped.charCodeAt(i + 3))
211​
212 result[j] = buffer >> 16
213 result[j + 1] = (buffer >> 8) & 0xff
214 result[j + 2] = buffer & 0xff
215 }
216​
217 return Result.succeed(result)
218 } catch (e) {
219 return Result.fail(
220 new EncodingError({
221 kind: "Decode",
222 module: "Base64",
223 input: stripped,
224 message: e instanceof Error ? e.message : "Invalid input"
225 })
226 )
227 }
229​
230/**
231 * Decodes a base64 (RFC4648) string into a UTF-8 string safely.
232 *
233 * **When to use**
234 *
235 * Use to decode a standard padded Base64 string into UTF-8 text without
236 * throwing on invalid input.
237 *
238 * **Details**
239 *
240 * Returns `Result.succeed` with the decoded text when decoding succeeds, or
241 * `Result.fail` with an `EncodingError` when the input is not valid base64.
242 *
243 * **Example** (Decoding Base64 strings)
244 *
245 * ```ts
246 * import { Encoding, Result } from "effect"
247 *
248 * const result = Encoding.decodeBase64String("aGVsbG8=")
249 * if (Result.isSuccess(result)) {
250 * console.log(result.success) // "hello"
251 * }
252 * ```
253 *
254 * @category decoding
255 * @since 2.0.0
256 */
257export const decodeBase64String = (str: string) => Result.map(decodeBase64(str), (_) => decoder.decode(_))
258​
259// -------------------------------------------------------------------------------------
260// Base64Url
261// -------------------------------------------------------------------------------------
262​
263/**
264 * Encodes the given value into a base64 (URL) `string`.
265 *
266 * **When to use**
267 *
268 * Use to encode text or bytes as an unpadded Base64Url string for contexts that
269 * require the URL-safe alphabet.
270 *
271 * **Details**
272 *
273 * String inputs are encoded as UTF-8 bytes before Base64Url encoding.
274 * `Uint8Array` inputs are encoded directly. The output removes `=` padding and
275 * replaces `+` with `-` and `/` with `_`.
276 *
277 * **Example** (Encoding URL-safe Base64)
278 *
279 * ```ts
280 * import { Encoding } from "effect"
281 *
282 * // URL-safe base64 encoding (uses - and _ instead of + and /)
283 * console.log(Encoding.encodeBase64Url("hello?")) // "aGVsbG8_"
284 *
285 * const bytes = new Uint8Array([72, 101, 108, 108, 111, 63])
286 * console.log(Encoding.encodeBase64Url(bytes)) // "SGVsbG8_"
287 * ```
288 *
289 * @see {@link decodeBase64Url} for decoding URL-safe Base64 to bytes
290 * @see {@link decodeBase64UrlString} for decoding URL-safe Base64 to UTF-8 text
291 * @see {@link encodeBase64} for standard padded Base64 output
292 *
293 * @category encoding
294 * @since 2.0.0
295 */
296export const encodeBase64Url: (input: Uint8Array | string) => string = (input) =>
297 typeof input === "string" ? base64UrlEncodeUint8Array(encoder.encode(input)) : base64UrlEncodeUint8Array(input)
298​
299/**
300 * Decodes a URL-safe base64 string into bytes safely.
301 *
302 * **When to use**
303 *
304 * Use to decode padded or unpadded Base64Url text into bytes without throwing
305 * on invalid input.
306 *
307 * **Details**
308 *
309 * Returns `Result.succeed` with a `Uint8Array` when decoding succeeds, or
310 * `Result.fail` with an `EncodingError` when the input is not valid URL-safe
311 * base64. Both padded and unpadded URL-safe base64 forms are accepted when
312 * otherwise valid.
313 *
314 * **Example** (Decoding URL-safe Base64 bytes)
315 *
316 * ```ts
317 * import { Encoding, Result } from "effect"
318 *
319 * const result = Encoding.decodeBase64Url("SGVsbG8_")
320 * if (Result.isSuccess(result)) {
321 * console.log(Array.from(result.success)) // [72, 101, 108, 108, 111, 63]
322 * }
323 * ```
324 *
325 * @category decoding
326 * @since 2.0.0
327 */
328export const decodeBase64Url = (str: string): Result.Result<Uint8Array, EncodingError> => {
329 const stripped = stripCrlf(str)
330 const length = stripped.length
331 if (length % 4 === 1) {
332 return Result.fail(
333 new EncodingError({
334 module: "Base64Url",
335 kind: "Decode",
336 input: stripped,
337 message: `Length should be a multiple of 4, but is ${length}`
338 })
339 )
340 }
341​
342 if (!/^[-_A-Z0-9]*?={0,2}$/i.test(stripped)) {
343 return Result.fail(
344 new EncodingError({
345 module: "Base64Url",
346 kind: "Decode",
347 input: stripped,
348 message: "Invalid input"
349 })
350 )
351 }
352​
353 // Some variants allow or require omitting the padding '=' signs
354 let sanitized = length % 4 === 2 ? `${stripped}==` : length % 4 === 3 ? `${stripped}=` : stripped
355 sanitized = sanitized.replace(/-/g, "+").replace(/_/g, "/")
356​
357 return decodeBase64(sanitized)
359​
360/**
361 * Decodes a URL-safe base64 string into a UTF-8 string safely.
362 *
363 * **When to use**
364 *
365 * Use to decode padded or unpadded Base64Url text into UTF-8 text without
366 * throwing on invalid input.
367 *
368 * **Details**
369 *
370 * Returns `Result.succeed` with the decoded text when decoding succeeds, or
371 * `Result.fail` with an `EncodingError` when the input is not valid URL-safe
372 * base64.
373 *
374 * **Example** (Decoding URL-safe Base64 strings)
375 *
376 * ```ts
377 * import { Encoding, Result } from "effect"
378 *
379 * const result = Encoding.decodeBase64UrlString("aGVsbG8_")
380 * if (Result.isSuccess(result)) {
381 * console.log(result.success) // "hello?"
382 * }
383 * ```
384 *
385 * @category decoding
386 * @since 2.0.0
387 */
388export const decodeBase64UrlString = (str: string) => Result.map(decodeBase64Url(str), (_) => decoder.decode(_))
389​
390// -------------------------------------------------------------------------------------
391// Hex
392// -------------------------------------------------------------------------------------
393​
394/**
395 * Encodes the given value into a hex `string`.
396 *
397 * **When to use**
398 *
399 * Use to encode text or bytes as lowercase hexadecimal text.
400 *
401 * **Example** (Encoding hex strings and bytes)
402 *
403 * ```ts
404 * import { Encoding } from "effect"
405 *
406 * // Encode a string to hex
407 * console.log(Encoding.encodeHex("hello")) // "68656c6c6f"
408 *
409 * // Encode binary data to hex
410 * const bytes = new Uint8Array([72, 101, 108, 108, 111])
411 * console.log(Encoding.encodeHex(bytes)) // "48656c6c6f"
412 * ```
413 *
414 * @category encoding
415 * @since 2.0.0
416 */
417export const encodeHex: (input: Uint8Array | string) => string = (input) =>
418 typeof input === "string" ? hexEncodeUint8Array(encoder.encode(input)) : hexEncodeUint8Array(input)
419​
420/**
421 * Decodes a hexadecimal string into bytes safely.
422 *
423 * **When to use**
424 *
425 * Use to decode hexadecimal text into bytes without throwing on invalid input.
426 *
427 * **Details**
428 *
429 * Returns `Result.succeed` with a `Uint8Array` when decoding succeeds, or
430 * `Result.fail` with an `EncodingError` when the input has an odd length or
431 * contains invalid hex characters.
432 *
433 * **Example** (Decoding hex bytes)
434 *
435 * ```ts
436 * import { Encoding, Result } from "effect"
437 *
438 * const result = Encoding.decodeHex("48656c6c6f")
439 * if (Result.isSuccess(result)) {
440 * console.log(Array.from(result.success)) // [72, 101, 108, 108, 111]
441 * }
442 * ```
443 *
444 * @category decoding
445 * @since 2.0.0
446 */
447export const decodeHex = (str: string): Result.Result<Uint8Array, EncodingError> => {
448 const bytes = new TextEncoder().encode(str)
449 if (bytes.length % 2 !== 0) {
450 return Result.fail(
451 new EncodingError({
452 module: "Hex",
453 kind: "Decode",
454 input: str,
455 message: `Length must be a multiple of 2, but is ${bytes.length}`
456 })
457 )
458 }
459​
460 try {
461 const length = bytes.length / 2
462 const result = new Uint8Array(length)
463 for (let i = 0; i < length; i++) {
464 const a = fromHexChar(bytes[i * 2])
465 const b = fromHexChar(bytes[i * 2 + 1])
466 result[i] = (a << 4) | b
467 }
468​
469 return Result.succeed(result)
470 } catch (e) {
471 return Result.fail(
472 new EncodingError({
473 module: "Hex",
474 kind: "Decode",
475 input: str,
476 message: e instanceof Error ? e.message : "Invalid input"
477 })
478 )
479 }
481​
482/**
483 * Decodes a hexadecimal string into a UTF-8 string safely.
484 *
485 * **When to use**
486 *
487 * Use to decode hexadecimal text into UTF-8 text without throwing on invalid
488 * input.
489 *
490 * **Details**
491 *
492 * Returns `Result.succeed` with the decoded text when decoding succeeds, or
493 * `Result.fail` with an `EncodingError` when the input is not valid hex.
494 *
495 * **Example** (Decoding hex strings)
496 *
497 * ```ts
498 * import { Encoding, Result } from "effect"
499 *
500 * const result = Encoding.decodeHexString("68656c6c6f")
501 * if (Result.isSuccess(result)) {
502 * console.log(result.success) // "hello"
503 * }
504 * ```
505 *
506 * @category decoding
507 * @since 2.0.0
508 */
509export const decodeHexString = (str: string) => Result.map(decodeHex(str), (_) => decoder.decode(_))
510​
511// -------------------------------------------------------------------------------------
512// internals
513// -------------------------------------------------------------------------------------
514​
515const encoder = new TextEncoder()
516const decoder = new TextDecoder()
517​
518const stripCrlf = (str: string) => str.replace(/[\n\r]/g, "")
519​
520// Base64 internals
521​
522const base64EncodeUint8Array = (bytes: Uint8Array) => {
523 const length = bytes.length
524​
525 let result = ""
526 let i: number
527​
528 for (i = 2; i < length; i += 3) {
529 result += base64abc[bytes[i - 2] >> 2]
530 result += base64abc[((bytes[i - 2] & 0x03) << 4) | (bytes[i - 1] >> 4)]
531 result += base64abc[((bytes[i - 1] & 0x0f) << 2) | (bytes[i] >> 6)]
532 result += base64abc[bytes[i] & 0x3f]
533 }
534​
535 if (i === length + 1) {
536 result += base64abc[bytes[i - 2] >> 2]
537 result += base64abc[(bytes[i - 2] & 0x03) << 4]
538 result += "=="
539 }
540​
541 if (i === length) {
542 result += base64abc[bytes[i - 2] >> 2]
543 result += base64abc[((bytes[i - 2] & 0x03) << 4) | (bytes[i - 1] >> 4)]
544 result += base64abc[(bytes[i - 1] & 0x0f) << 2]
545 result += "="
546 }
547​
548 return result
550​
551function getBase64Code(charCode: number) {
552 if (charCode >= base64codes.length) {
553 throw new TypeError(`Invalid character ${String.fromCharCode(charCode)}`)
554 }
555​
556 const code = base64codes[charCode]
557 if (code === 255) {
558 throw new TypeError(`Invalid character ${String.fromCharCode(charCode)}`)
559 }
560​
561 return code
563​
564const base64abc = [
565 "A",
566 "B",
567 "C",
568 "D",
569 "E",
570 "F",
571 "G",
572 "H",
573 "I",
574 "J",
575 "K",
576 "L",
577 "M",
578 "N",
579 "O",
580 "P",
581 "Q",
582 "R",
583 "S",
584 "T",
585 "U",
586 "V",
587 "W",
588 "X",
589 "Y",
590 "Z",
591 "a",
592 "b",
593 "c",
594 "d",
595 "e",
596 "f",
597 "g",
598 "h",
599 "i",
600 "j",
601 "k",
602 "l",
603 "m",
604 "n",
605 "o",
606 "p",
607 "q",
608 "r",
609 "s",
610 "t",
611 "u",
612 "v",
613 "w",
614 "x",
615 "y",
616 "z",
617 "0",
618 "1",
619 "2",
620 "3",
621 "4",
622 "5",
623 "6",
624 "7",
625 "8",
626 "9",
627 "+",
628 "/"
630​
631const base64codes = [
632 255,
633 255,
634 255,
635 255,
636 255,
637 255,
638 255,
639 255,
640 255,
641 255,
642 255,
643 255,
644 255,
645 255,
646 255,
647 255,
648 255,
649 255,
650 255,
651 255,
652 255,
653 255,
654 255,
655 255,
656 255,
657 255,
658 255,
659 255,
660 255,
661 255,
662 255,
663 255,
664 255,
665 255,
666 255,
667 255,
668 255,
669 255,
670 255,
671 255,
672 255,
673 255,
674 255,
675 62,
676 255,
677 255,
678 255,
679 63,
680 52,
681 53,
682 54,
683 55,
684 56,
685 57,
686 58,
687 59,
688 60,
689 61,
690 255,
691 255,
692 255,
693 0,
694 255,
695 255,
696 255,
697 0,
698 1,
699 2,
700 3,
701 4,
702 5,
703 6,
704 7,
705 8,
706 9,
707 10,
708 11,
709 12,
710 13,
711 14,
712 15,
713 16,
714 17,
715 18,
716 19,
717 20,
718 21,
719 22,
720 23,
721 24,
722 25,
723 255,
724 255,
725 255,
726 255,
727 255,
728 255,
729 26,
730 27,
731 28,
732 29,
733 30,
734 31,
735 32,
736 33,
737 34,
738 35,
739 36,
740 37,
741 38,
742 39,
743 40,
744 41,
745 42,
746 43,
747 44,
748 45,
749 46,
750 47,
751 48,
752 49,
753 50,
754 51
756​
757// Base64Url internals
758​
759const base64UrlEncodeUint8Array = (data: Uint8Array) =>
760 base64EncodeUint8Array(data).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_")
761​
762// Hex internals
763​
764const hexEncodeUint8Array = (bytes: Uint8Array) => {
765 let result = ""
766 for (let i = 0; i < bytes.length; ++i) {
767 result += bytesToHex[bytes[i]]
768 }
769​
770 return result
772​
773const fromHexChar = (byte: number) => {
774 if (48 <= byte && byte <= 57) {
775 return byte - 48
776 }
777​
778 if (97 <= byte && byte <= 102) {
779 return byte - 97 + 10
780 }
781​
782 if (65 <= byte && byte <= 70) {
783 return byte - 65 + 10
784 }
785​
786 throw new TypeError("Invalid input")
788​
789const bytesToHex = [
790 "00",
791 "01",
792 "02",
793 "03",
794 "04",
795 "05",
796 "06",
797 "07",
798 "08",
799 "09",
800 "0a",
801 "0b",
802 "0c",
803 "0d",
804 "0e",
805 "0f",
806 "10",
807 "11",
808 "12",
809 "13",
810 "14",
811 "15",
812 "16",
813 "17",
814 "18",
815 "19",
816 "1a",
817 "1b",
818 "1c",
819 "1d",
820 "1e",
821 "1f",
822 "20",
823 "21",
824 "22",
825 "23",
826 "24",
827 "25",
828 "26",
829 "27",
830 "28",
831 "29",
832 "2a",
833 "2b",
834 "2c",
835 "2d",
836 "2e",
837 "2f",
838 "30",
839 "31",
840 "32",
841 "33",
842 "34",
843 "35",
844 "36",
845 "37",
846 "38",
847 "39",
848 "3a",
849 "3b",
850 "3c",
851 "3d",
852 "3e",
853 "3f",
854 "40",
855 "41",
856 "42",
857 "43",
858 "44",
859 "45",
860 "46",
861 "47",
862 "48",
863 "49",
864 "4a",
865 "4b",
866 "4c",
867 "4d",
868 "4e",
869 "4f",
870 "50",
871 "51",
872 "52",
873 "53",
874 "54",
875 "55",
876 "56",
877 "57",
878 "58",
879 "59",
880 "5a",
881 "5b",
882 "5c",
883 "5d",
884 "5e",
885 "5f",
886 "60",
887 "61",
888 "62",
889 "63",
890 "64",
891 "65",
892 "66",
893 "67",
894 "68",
895 "69",
896 "6a",
897 "6b",
898 "6c",
899 "6d",
900 "6e",
901 "6f",
902 "70",
903 "71",
904 "72",
905 "73",
906 "74",
907 "75",
908 "76",
909 "77",
910 "78",
911 "79",
912 "7a",
913 "7b",
914 "7c",
915 "7d",
916 "7e",
917 "7f",
918 "80",
919 "81",
920 "82",
921 "83",
922 "84",
923 "85",
924 "86",
925 "87",
926 "88",
927 "89",
928 "8a",
929 "8b",
930 "8c",
931 "8d",
932 "8e",
933 "8f",
934 "90",
935 "91",
936 "92",
937 "93",
938 "94",
939 "95",
940 "96",
941 "97",
942 "98",
943 "99",
944 "9a",
945 "9b",
946 "9c",
947 "9d",
948 "9e",
949 "9f",
950 "a0",
951 "a1",
952 "a2",
953 "a3",
954 "a4",
955 "a5",
956 "a6",
957 "a7",
958 "a8",
959 "a9",
960 "aa",
961 "ab",
962 "ac",
963 "ad",
964 "ae",
965 "af",
966 "b0",
967 "b1",
968 "b2",
969 "b3",
970 "b4",
971 "b5",
972 "b6",
973 "b7",
974 "b8",
975 "b9",
976 "ba",
977 "bb",
978 "bc",
979 "bd",
980 "be",
981 "bf",
982 "c0",
983 "c1",
984 "c2",
985 "c3",
986 "c4",
987 "c5",
988 "c6",
989 "c7",
990 "c8",
991 "c9",
992 "ca",
993 "cb",
994 "cc",
995 "cd",
996 "ce",
997 "cf",
998 "d0",
999 "d1",
1000 "d2",
1001 "d3",
1002 "d4",
1003 "d5",
1004 "d6",
1005 "d7",
1006 "d8",
1007 "d9",
1008 "da",
1009 "db",
1010 "dc",
1011 "dd",
1012 "de",
1013 "df",
1014 "e0",
1015 "e1",
1016 "e2",
1017 "e3",
1018 "e4",
1019 "e5",
1020 "e6",
1021 "e7",
1022 "e8",
1023 "e9",
1024 "ea",
1025 "eb",
1026 "ec",
1027 "ed",
1028 "ee",
1029 "ef",
1030 "f0",
1031 "f1",
1032 "f2",
1033 "f3",
1034 "f4",
1035 "f5",
1036 "f6",
1037 "f7",
1038 "f8",
1039 "f9",
1040 "fa",
1041 "fb",
1042 "fc",
1043 "fd",
1044 "fe",
1045 "ff"