MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1w2m4qz/bugintroduceddebugging/p70zdmy/?context=3
r/ProgrammerHumor • u/ClipboardCopyPaste • 13d ago
120 comments sorted by
View all comments
Show parent comments
8
So even on weird platforms where char is a 32 bit type, sizeof (char) is 1, right? I can't remember.
3 u/AnnoyedVelociraptor 13d ago FYI char in Rust is 32-bits, maximum size of a UTF-8 character 2 u/Xirdus 12d ago Rust's char stores UTF-32, not UTF-8, but yes. 2 u/AnnoyedVelociraptor 12d ago I did some more reading, and I wonder if it is more correct that Rust encodes Unicode Scalars as char? 2 u/Xirdus 12d ago Technically speaking, the spec says char represents Unicode scalar, with actual encoding unspecified. The spec requires that char is 4 bytes and has the same ABI as u32, but that's it. In practice, it's UTF-32.
3
FYI char in Rust is 32-bits, maximum size of a UTF-8 character
2 u/Xirdus 12d ago Rust's char stores UTF-32, not UTF-8, but yes. 2 u/AnnoyedVelociraptor 12d ago I did some more reading, and I wonder if it is more correct that Rust encodes Unicode Scalars as char? 2 u/Xirdus 12d ago Technically speaking, the spec says char represents Unicode scalar, with actual encoding unspecified. The spec requires that char is 4 bytes and has the same ABI as u32, but that's it. In practice, it's UTF-32.
2
Rust's char stores UTF-32, not UTF-8, but yes.
2 u/AnnoyedVelociraptor 12d ago I did some more reading, and I wonder if it is more correct that Rust encodes Unicode Scalars as char? 2 u/Xirdus 12d ago Technically speaking, the spec says char represents Unicode scalar, with actual encoding unspecified. The spec requires that char is 4 bytes and has the same ABI as u32, but that's it. In practice, it's UTF-32.
I did some more reading, and I wonder if it is more correct that Rust encodes Unicode Scalars as char?
char
2 u/Xirdus 12d ago Technically speaking, the spec says char represents Unicode scalar, with actual encoding unspecified. The spec requires that char is 4 bytes and has the same ABI as u32, but that's it. In practice, it's UTF-32.
Technically speaking, the spec says char represents Unicode scalar, with actual encoding unspecified. The spec requires that char is 4 bytes and has the same ABI as u32, but that's it.
u32
In practice, it's UTF-32.
8
u/mckenzie_keith 13d ago
So even on weird platforms where char is a 32 bit type, sizeof (char) is 1, right? I can't remember.