comprehensive-rust icon indicating copy to clipboard operation
comprehensive-rust copied to clipboard

Specify Unicode encoding

Open bibhas2 opened this issue 2 years ago • 3 comments
trafficstars

Page: https://google.github.io/comprehensive-rust/hello-world.html

It states Rust strings can contain Unicode characters. This is not super helpful. We need to know what encoding is supported by the string literal. Most C++ compilers will assume UTF-8 as the encoding by default. It will be helpful if this page can state the encoding.

bibhas2 avatar Dec 22 '22 19:12 bibhas2

This is not super helpful. We need to know what encoding is supported by the string literal. Most C++ compilers will assume UTF-8 as the encoding by default. It will be helpful if this page can state the encoding.

Yeah, good point! This is something I mention during class: .rs files must be valid UTF-8 — it's a compilation error if they're not. The compiler will say something like

error: couldn't read src/main.rs: stream did not contain valid UTF-8

The page doesn't point this out since it's just a slide. I'm considering adding speaker notes to be able to elaborate on these things.

mgeisler avatar Dec 23 '22 12:12 mgeisler

Hi @mgeisler, it will be tremendously helpful if that line simply said:

Rust strings contain any UTF-8 encoded Unicode characters, such as emoji.

bibhas2 avatar Dec 23 '22 14:12 bibhas2

Thanks @bibhas2, I'll update the page like you suggest in #81.

mgeisler avatar Dec 28 '22 08:12 mgeisler