Byte length and visible character count can differ.
LET’S PICTURE IT
A word can contain a symbol that occupies several encoded bytes even though it looks like one character.
SEE IT FOR YOURSELF
Build a transfer call from typed fieldsStep 1 / 4
The standard transfer interface takes an address and a raw integer amount. This diagram uses address one and amount one hundred.
The standard transfer interface takes an address and a raw integer amount. This diagram uses address one and amount one hundred.Keccak-256 of the canonical signature supplies the first four bytes. The transfer selector is a9059cbb.An address is twenty bytes. Standard ABI encoding adds twelve zero bytes on the left to fill one thirty-two-byte word.The integer one hundred is hex 64, left-padded in word one. Selector plus two words produces sixty-eight bytes of standard calldata.
Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.
A string is encoded data
Solidity string is used for text-like variable-length data. Applications commonly interpret its bytes as UTF-8. The language does not make every possible byte sequence a meaningful human word.
Length is a byte question in encoding
For example, the UTF-8 text é takes two bytes. An ABI dynamic string stores a byte length, then the encoded bytes and padding. A visible-character counter is not a reliable substitute.
Normalization can change bytes
Two visually similar strings may use different Unicode compositions and therefore hash differently. Contracts and signatures operate on exact encoded data, so applications need explicit text conventions where identity matters.
Try a non-ASCII message
Choose setMessage(string) in the ABI lab and encode a short message containing a multibyte character. Follow its offset, byte length and padded data rather than counting what the screen appears to show.
Read the example
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract LearningExample {
function byteLength(string calldata text)
external pure returns (uint256)
{
return bytes(text).length;
}
}
This returns byte length rather than a human-perceived character count.