def image.svg.uri.bytes

gralha-svg-render@0.1.0.1 · svg.bend:3810

import gralha-svg-render@0.1.0.1/svg.bend as Svg
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
import gralha-bytes@0.1.0.1/bytes.bend as Bin

3810def image.svg.uri.bytes(+s: String, +out: Bin.Bytes) -> Bin.Bytes:
3811  match s:
3812    case SNil{}: out
3813    case SCon{Chr{37}, SCon{Chr{a}, SCon{Chr{b}, rest}}}:
3814      U.branch(Bin.Bytes, Bin.uri.hex.valid(a) && Bin.uri.hex.valid(b), _ => image.svg.uri.bytes(rest, Bin.bytes.push(out, (U.hex.digit(a) * 16 + U.hex.digit(b) : U32))), _ => Bin.bytes.empty())
3815    case SCon{Chr{c}, rest}:
3816      U.branch(Bin.Bytes, Bool.not(U32.is_eq(c, 37)), _ => image.svg.uri.bytes(rest, image.svg.utf8.push(out, c)), _ => Bin.bytes.empty())

Uses (18)

Used by (1)