Unicode gives characters numbers. For example, A is 65 and 友 is 21451. Its range includes letters from many languages and symbols such as emoji. section 1.3
In Rust, a character has the type `char`. Familiar characters with small numbers can fit in a `u8`, which holds numbers from 0 through 255, but not every Unicode character can. section 1.3
fn main() {
let str1 = "Hello!";
println!("str1 is {} bytes and also {} characters.", str1.len(), str1.chars().count());
let str2 = "안녕!";
println!("str2 is {} bytes but only {} characters.", str2.len(), str2.chars().count());
}
Try the string-length example: `Hello!` takes 6 bytes for 6 characters, while `안녕!` takes 7 bytes for just 3. Use `.chars().count()` when you need the character count rather than the byte length. section 1.3







