4 ms·
They are both unicode. A `String` is unicode encoded as `UTF-8` whereas a `char` is simply a single, un-encoded, code point. An array of `char` would technical
by ChrisSD 6y ago
They are both unicode. A `String` is unicode encoded as `UTF-8` whereas a `char` is simply a single, un-encoded, code point.
An array of `char` would technically be UTF-32. Which isn't particularly useful, imho.
- pelliphant 6y agook, thnx for clarifying.
- Tobu 6y agoA char is a scalar value, rather: https://doc.rust-lang.org/std/primitive.char.html https://doc.rust-lang.org/std/primitive.char.html
- ChrisSD 6y agoYou're right, of course. Unicode terminology always trips me up. I have to remember that a scalar value is almost the same as a code point except that it excludes surrogates.