def Utf8.length

bend-trace-context@0.2.0.0 · trace_context.bend:2006

import bend-trace-context@0.2.0.0/trace_context.bend as TraceContext
import Base

2006# The UTF-8 octets of a text, in which the laws state every budget. Emission
2007# measures keys and values with it, at most 256 characters each; parsing
2008# measures received text with Utf8.left instead, which stops counting past
2009# the budget.
2010def Utf8.length(text: String) -> Nat:
2011  match text:
2012    case SNil{}:
2013      0n
2014    case SCon{char, tail}:
2015      Nat.add(Utf8.width(char), Utf8.length(tail))

Uses (4)

Used by (1)