The purpose of this article is to demonstrate the current unexpected behavior of the functions left(), len(), lenb() and leftb().
left(), len(), lenb()
leftb()
When using left(), leftb(), len() and lenb(), there is unexpected behavior in how these functions count certain characters, such as emojis.
left()
len()
lenb()
The following results demonstrate that currently left() and leftb() do not provide the expected outputs based on their function documentation:
len() counts an emoji as 1 character (expected)
lenb() counts an emoji as 4 bytes (expected)
left() counts an emoji as 2 characters (unexpected, expected 1)
leftb() counts an emoji as 2 bytes (unexpected, expected be 4)
left and leftb() always ouput the same result (2 in this case)
As a result of this inconsistency, it is not possible to truncate a length of text to a specific number of bytes.
Check the string’s byte length using lenb(ri!text). If it's within the limit, return the string.
lenb(ri!text)
If it exceeds the limit, use regexfirstmatch() to trim one character at a time.
regexfirstmatch()
Repeat step 2 until the byte length is within the limit.
Note: This method fails if more than 529 characters need to be removed (due to recursion limits). Emoji-heavy messages are more likely to cause this issue.
This article applies to all versions of Appian.
Last Reviewed: March 2026