b64.bend checks
raw source on the hub · import cswap-bend-cli@0.1.0.0/b64.bend as B64
1 import
import Base
Types
type Quad source · line 146 · raw
Data
The next four characters of the input as sextets, or the end, or a bad tail.
QEndQuad
QBadQuad
Q@w:U32 -> @x:U32 -> @y:U32 -> @z:U32 -> @rest:String -> Quad
Definitions
def utf8.cat.pick source · line 8 · raw
@a:Bool -> @b:Bool -> @d:Bool -> @+c:U32 -> @rest:List<&2, U32> -> List<&2, U32>
def utf8.cat source · line 19 · raw
@+c:U32 -> @rest:List<&2, U32> -> List<&2, U32>
def utf8.encode source · line 23 · raw
@s:String -> List<&2, U32>
The UTF-8 bytes of a string.
def sel source · line 30 · raw
@c:Bool -> @x:U32 -> @y:U32 -> U32
def sel.b source · line 37 · raw
@c:Bool -> @x:Bool -> @y:Bool -> Bool
def utf8.len source · line 45 · raw
@+b:U32 -> U32
Continuation bytes a lead byte announces.
def utf8.mask source · line 48 · raw
@+n:U32 -> U32
def utf8.need source · line 54 · raw
@+b:U32 -> @+need:U32 -> U32
The decoder state is (need, cp): continuation bytes still due and the code point so far. These three give the next need, the next cp, and whether cp is complete.
def utf8.cp source · line 57 · raw
@+b:U32 -> @+need:U32 -> @+cp:U32 -> U32
def utf8.emit source · line 60 · raw
@+b:U32 -> @+need:U32 -> Bool
def utf8.put source · line 63 · raw
@emit:Bool -> @c:U32 -> @rest:String -> String
def utf8.decode.go source · line 71 · raw
@bs:List<&2, U32> -> @+need:U32 -> @+cp:U32 -> String
Decode UTF-8 bytes (lenient on malformed input).
def utf8.decode source · line 79 · raw
@bs:List<&2, U32> -> String
def b64.char source · line 84 · raw
@+n:U32 -> Char
def b64.enc.go source · line 90 · raw
@bs:List<&2, U32> -> String
def encode_bytes source · line 105 · raw
@bs:List<&2, U32> -> String
Base64 of the bytes.
def encode source · line 109 · raw
@s:String -> String
Base64 of the UTF-8 form of the text.
def b64.val source · line 113 · raw
@+c:U32 -> U32
0..63 the sextet, 64 for =, 255 for anything else.
def b64.quad.emit source · line 121 · raw
@p3:Bool -> @p4:Bool -> @a:U32 -> @b:U32 -> @c:U32 -> @r:List<&2, U32> -> Maybe<&2, List<&2, U32>>
def b64.quad.pick source · line 130 · raw
@ok:Bool -> @p3:Bool -> @p4:Bool -> @+w:U32 -> @+x:U32 -> @+y:U32 -> @+z:U32 -> @rest:Maybe<&2, List<&2, U32>> -> Maybe<&2, List<&2, U32>>
def b64.dec.quad source · line 141 · raw
@+w:U32 -> @+x:U32 -> @+y:U32 -> @+z:U32 -> @rest:Maybe<&2, List<&2, U32>> -> Maybe<&2, List<&2, U32>>
def b64.quad.of4 source · line 151 · raw
@c1:U32 -> @c2:U32 -> @c3:U32 -> @s:String -> Quad
def b64.quad.of3 source · line 158 · raw
@c1:U32 -> @c2:U32 -> @s:String -> Quad
def b64.quad.of2 source · line 165 · raw
@c1:U32 -> @s:String -> Quad
def b64.quad.of source · line 172 · raw
@s:String -> Quad
def b64.dec.go source · line 182 · raw
@fuel:Nat -> @q:Quad -> Maybe<&2, List<&2, U32>>
fuel is the input length, at least the number of quads.
def b64.dec.start source · line 193 · raw
@+s:String -> Maybe<&2, List<&2, U32>>
def b64.strip.put source · line 196 · raw
@sp:Bool -> @c:Char -> @rest:String -> String
def b64.strip source · line 203 · raw
@s:String -> String
def decode_bytes source · line 211 · raw
@s:String -> Maybe<&2, List<&2, U32>>
Decode to bytes; None on a bad character, bad padding or a short tail.
def b64.text source · line 214 · raw
@m:Maybe<&2, List<&2, U32>> -> Maybe<&2, String>
def decode source · line 222 · raw
@s:String -> Maybe<&2, String>
Decode to UTF-8 text.