def utf8.encode.go

bend-kit-protobuf@0.2.0.0 · protobuf.bend:789

import bend-kit-protobuf@0.2.0.0/protobuf.bend as Protobuf
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as B

789def utf8.encode.go(s: String, out: B.Bytes) -> Result<&2, &1, Error, B.Bytes>:
790  match s:
791    case SNil{}:
792      Done{out}
793    case SCon{Chr{+c}, tail}:
794      do Result<&2, &1, Error, B.Bytes>:
795        ok : Unit <- require(utf8.scalar(c), InvalidUtf8{})
796        next : B.Bytes <- utf8.push(utf8.width(c), c, out)
797        utf8.encode.go(tail, next)

Uses (11)

Used by (1)