Visible characters and encoded bytes are different counts.
LET’S PICTURE IT
One printed symbol can need several storage boxes when written in a byte alphabet.
SEE IT FOR YOURSELF
Follow a dynamic string from head to tailStep 1 / 4
This example encodes one string parameter with value hello. A dynamic argument uses an offset in its head, even when it is the only argument.
This example encodes one string parameter with value hello. A dynamic argument uses an offset in its head, even when it is the only argument.At argument byte 32, the string tail begins with length five. This counts the UTF-8 payload bytes and excludes all padding.At argument byte 64, read 68 65 6c 6c 6f for hello. Twenty-seven following zero bytes fill the final content word.The encoding uses ninety-six argument bytes: one offset word, one length word and one padded content word. A normal function call adds a four-byte selector before these bytes.
Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.
Choose the exact text
A string is encoded as UTF-8 bytes. The text é uses two bytes, c3 a9, in its precomposed form. A displayed symbol is not automatically one byte.
Measure encoded bytes
The length word for this example is two. JavaScript string length counts UTF-16 code units, so it is not a general substitute for a UTF-8 byte measurement.
Watch equivalent appearances
An accented letter can also be expressed with a base letter and a combining mark. Similar-looking text may have different bytes unless an application deliberately normalizes it.
Verify before adding padding
First encode the text, then count those bytes, then pad the content block. Do not count the hex prefix, printed hex digits or trailing zeros as original content.
Trace a local example
types: string
values: ["é"]
no function selector prefix
word 0 · argument offset 0 bytes
0x0000000000000000000000000000000000000000000000000000000000000020
word 1 · argument offset 32 bytes
0x0000000000000000000000000000000000000000000000000000000000000002
word 2 · argument offset 64 bytes
0xc3a9000000000000000000000000000000000000000000000000000000000000
The length word is 2 even though the displayed text looks like one letter.