What you will do
You will run the prepared expression in the playground above, change one input at a time, and explain the result. Start in CEL only, then repeat the same rule in CEL + JSON.
How it works
For strings, size() counts Unicode code points, not UTF-8 bytes. The text Žilina 👋 contains six letters, one space, and one emoji, so this example returns 8. This definition is stable across hosts even though a user-perceived character can sometimes contain multiple code points.
Read the prepared example
The CEL + JSON rule is:
text.size()Its input is:
{
"text": "Žilina 👋"
}The CEL only tab contains the values and the rule in one expression. The enabled cel.bind() extension keeps each name local to its final argument.
Evaluation step by step
- CEL reads the value as one Unicode string.
size()counts its Unicode code points.- The result is the integer
8.
Your task
- Run both modes and confirm 8.
- Remove the emoji and run again.
- Try
'👨👩👧👦'.size()and note that a visual symbol can use several code points.
Expected observation: Removing the emoji returns 7; the family emoji demonstrates the difference between code points and visual graphemes.
Common mistake
Do not use string size() as a byte limit for storage or networking. Byte length is a different measurement.
Show the explanation
The CEL string definition makes size() count Unicode code points.
Knowledge check
Why is the result not the UTF-8 byte length?
Key takeaway
Know what is being counted: string size is a code-point count, not a byte count.
Sources
CEL-DEV— official CEL overview.CEL-LANG— official CEL language definition.CEL-GO-BIND— official documentation for the optionalcel.bind()extension used by the self-contained tab.