UTF-8
The way Rust stores text: each character takes 1 to 4 bytes.
UTF-8 is a variable-width encoding of Unicode scalar values: ASCII characters take 1 byte and others take 2, 3, or 4. Every Rust String and str is valid UTF-8.
Loading interactive…
Examples
"a".len()is 1,"é".len()is 2 and"🦀".len()is 4:len()counts bytes, not characters.
See also