How are 4 bytes chars are represented in C#? Like one char or a set of 2 chars?
var someCharacter = 'x'; //put 4 bytes UTF-16 character
There are 2,097,152 possible 4-byte characters, but not all of them are valid and not all of the valid characters are used. This chart shows selected groups of 4-byte characters, including emojis, symbols, and Egyptian hieroglyphs.
Integers are commonly stored using a word of memory, which is 4 bytes or 32 bits, so integers from 0 up to 4,294,967,295 (232 - 1) can be stored.
C# can only store characters from the Basic Multilingual Plane in the char
type. For characters outside this plane two char
s must be used - called surrogates.
You can also use a string literal such as:
string s = "\U0001D11E";
See UTF-16.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With