Bytes on both platforms, a byte array on the JVM and a Uint8Array in JavaScript, and their encodings: UTF-8, hex, base64 and base64url.
Each decoder returns nil for text that isn't valid. The decoders of base64 are strict on both platforms: they take only the alphabet, the padding where RFC 4648 asks for it and pad bits of zero, so that no two texts decode to the same bytes.
Bytes on both platforms, a byte array on the JVM and a Uint8Array in JavaScript, and their encodings: UTF-8, hex, base64 and base64url. Each decoder returns nil for text that isn't valid. The decoders of base64 are strict on both platforms: they take only the alphabet, the padding where RFC 4648 asks for it and pad bits of zero, so that no two texts decode to the same bytes.
(at b i)The byte at the index i of b, as a number from 0 to 255.
The byte at the index `i` of `b`, as a number from 0 to 255.
(base64 b)The bytes b in base64, with padding.
The bytes `b` in base64, with padding.
(base64url b)(base64url b {:keys [padding?] :as opts})The bytes b in base64url, the alphabet of base64 for URLs and file
names, with opts:
The bytes `b` in base64url, the alphabet of base64 for URLs and file names, with `opts`: - :padding?, true to pad the text to a multiple of four characters, as base64 is. It's false by default, as in JOSE and most other uses.
(bytes? x)Whether x is bytes: a byte array on the JVM, or a Uint8Array in
JavaScript (and a Buffer in Node is one).
Whether `x` is bytes: a byte array on the JVM, or a Uint8Array in JavaScript (and a Buffer in Node is one).
(concat & bs)The bytes of each of bs, one after another, as new bytes.
The bytes of each of `bs`, one after another, as new bytes.
(decode b)The text of the UTF-8 bytes b. A byte order mark stays, and bytes that
aren't UTF-8 become U+FFFD, though the JVM and JavaScript can differ in
how many.
The text of the UTF-8 bytes `b`. A byte order mark stays, and bytes that aren't UTF-8 become U+FFFD, though the JVM and JavaScript can differ in how many.
(encode s)The bytes of the text s in UTF-8. A lone surrogate, which UTF-8 can't
hold, becomes U+FFFD on both platforms, as with TextEncoder.
The bytes of the text `s` in UTF-8. A lone surrogate, which UTF-8 can't hold, becomes U+FFFD on both platforms, as with TextEncoder.
(from-base64 s)The bytes of the base64 text s, which has its padding, or nil when it
isn't base64.
The bytes of the base64 text `s`, which has its padding, or nil when it isn't base64.
(from-base64url s)The bytes of the base64url text s, with or without padding, or nil
when it isn't base64url.
The bytes of the base64url text `s`, with or without padding, or nil when it isn't base64url.
(from-hex s)The bytes of the hexadecimal text s, in upper or lower case, or nil
when it isn't hexadecimal or has an odd number of digits.
The bytes of the hexadecimal text `s`, in upper or lower case, or nil when it isn't hexadecimal or has an odd number of digits.
(hex b)The bytes b in hexadecimal, two digits in lower case for each byte.
The bytes `b` in hexadecimal, two digits in lower case for each byte.
(of xs)The bytes of the numbers xs, each from 0 to 255.
The bytes of the numbers `xs`, each from 0 to 255.
(same-text? a b)Whether a and b are the same text, in a time that doesn't tell where
they differ. Nil or another value is never the same.
Whether `a` and `b` are the same text, in a time that doesn't tell where they differ. Nil or another value is never the same.
(same? a b)Whether a and b are the same bytes, in a time that doesn't tell where
they differ, as a comparison of secrets needs. Nil or another value is
never the same.
Whether `a` and `b` are the same bytes, in a time that doesn't tell where they differ, as a comparison of secrets needs. Nil or another value is never the same.
(slice b start)(slice b start end)The bytes of b from start to end, or to the end of b, as new
bytes. It throws when they aren't within b.
The bytes of `b` from `start` to `end`, or to the end of `b`, as new bytes. It throws when they aren't within `b`.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |