I am learning Rust and I wanted to play around with slices, but this made me "discover" that string literals "o" and "ó" differ in length.
This code:
fn main() {
let o = String::from("o");
let oo = String::from("ó");
println!("o length: {}, ó length: {}", o.len(), oo.len());
}
returns:
o length: 1, ó length: 2
The result of:
println!("{}", String::from("ó"));
println!("{}", "ó");
Is exactly the same.
I am asking this because I am no master of Strings, string literals, bytes and encoding, especially in Rust. Why is the length of o = 1 and of ó = 2?